Page 1 of 1

Windows API mouse commands no longer work

Posted: Sat Jan 26, 2013 8:31 pm
by Samuel
On PB 5.0 they work fine, but i recently downloaded the newest beta and they no longer seem to work.
Any help is appreciated.


Code: Select all


If OpenWindow(0, 0, 0, 800, 600, "Test",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
     StartDrawing(WindowOutput(0)) 
        Box(0,0,800,600,RGB(0,0,0))
     StopDrawing()
EndIf



Repeat
     
    Event= WaitWindowEvent()   


    Select event
      Case #WM_LBUTTONUP
        Debug "Left Button Up"
      Case #WM_RBUTTONUP
        Debug "Right Button Up"
    EndSelect     

     
  Until Event = #PB_Event_CloseWindow
  End


Re: Windows API mouse commands no longer work

Posted: Sat Jan 26, 2013 8:38 pm
by ts-soft
This events native in PB5.10

Code: Select all

If OpenWindow(0, 0, 0, 800, 600, "Test",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  StartDrawing(WindowOutput(0))
  Box(0,0,800,600,RGB(0,0,0))
  StopDrawing()
EndIf

Repeat
  
  Event= WaitWindowEvent()   
  
  
  Select event
    Case #PB_Event_LeftClick
      Debug "Left Button Up"
    Case #PB_Event_RightClick
      Debug "Right Button Up"
  EndSelect     
  
  
Until Event = #PB_Event_CloseWindow
End


Re: Windows API mouse commands no longer work

Posted: Sat Jan 26, 2013 8:42 pm
by luis
And if you want windows messages just use SetWindowCallback(), look at the doc and you will see windows #WM_ messages were never documented as possible return values for WaitWindowEvent().

Code: Select all

Procedure wc (hWnd, uMsg, wParam, lParam)   
 Select uMsg
  Case #WM_LBUTTONUP
    Debug "Left Button Up"
  Case #WM_RBUTTONUP
    Debug "Right Button Up"
 EndSelect     

 ProcedureReturn #PB_ProcessPureBasicEvents 
EndProcedure 

If OpenWindow(0, 0, 0, 800, 600, "Test",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
     StartDrawing(WindowOutput(0))
        Box(0,0,800,600,RGB(0,0,0))
     StopDrawing()
EndIf

SetWindowCallback(@wc())

Repeat
 Event = WaitWindowEvent()   
Until Event = #PB_Event_CloseWindow

End
 

Re: Windows API mouse commands no longer work

Posted: Sat Jan 26, 2013 9:40 pm
by Samuel
Thanks ts-soft that takes care of my problem, but I have one question. How do you tell if the mouse button was pressed or released? Looking in the help files
I only see options for right,left, and left double click.

Re: Windows API mouse commands no longer work

Posted: Sat Jan 26, 2013 9:53 pm
by netmaestro
How do you tell if the mouse button was pressed or released?
Pressed vs. released is only native in the keyboard library for screens. See the solution from luis above for acheiving it on a window.

Re: Windows API mouse commands no longer work

Posted: Sun Jan 27, 2013 9:15 am
by VB6_to_PBx
is the Code below how the next PureBasic version will be ?

Code: Select all


;        Windows_Message__Mouse_Events__v1.pb

;        Post subject: Windows API mouse commands no longer work
;        http://www.purebasic.fr/english/viewtopic.php?f=13&t=53112


Procedure wc (hWnd, uMsg, wParam, lParam)   
    Select uMsg
    Case #WM_LBUTTONDOWN
         SetWindowTitle(0,"Left Button Down")
    Case #WM_LBUTTONUP
         SetWindowTitle(0,"Left Button Up")
    Case #WM_LBUTTONDBLCLK
         SetWindowTitle(0,"Left Button DoubeClick")
    Case #WM_RBUTTONDOWN
         SetWindowTitle(0,"Right Button Down")
    Case #WM_RBUTTONUP
         SetWindowTitle(0,"Right Button Up")
    Case #WM_RBUTTONDBLCLK
         SetWindowTitle(0,"Right Button DoubeClick")
    EndSelect     

    ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

OpenWindow(0, 0, 0, 800, 600, "Test",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
     
StartDrawing(WindowOutput(0))
    Box(0,0,800,600,RGB(0,0,0))
StopDrawing()

SetWindowCallback(@wc())

Repeat : Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow


 

so this older 5.0 version Code below , is not planned to work correctly in the next final version release ?
you will now need to use the above Code in all future releases ?

Code: Select all


;        Windows_Message__Mouse_Events__v2.pb

;        Post subject: Windows API mouse commands no longer work
;        http://www.purebasic.fr/english/viewtopic.php?f=13&t=53112

OpenWindow(0, 0, 0, 800, 600, "Test",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
    
StartDrawing(WindowOutput(0))
    Box(0,0,800,600,RGB(0,0,0))
StopDrawing()

Repeat
 
Event= WaitWindowEvent()   
    Select event
    Case #PB_Event_CloseWindow
         End
    Case #WM_LBUTTONDOWN
         SetWindowTitle(0,"Left Button Down")
    Case #WM_LBUTTONUP
         SetWindowTitle(0,"Left Button Up")
    Case #WM_LBUTTONDBLCLK
         SetWindowTitle(0,"Left Button DoubeClick")
    Case #WM_RBUTTONDOWN
         SetWindowTitle(0,"Right Button Down")
    Case #WM_RBUTTONUP
         SetWindowTitle(0,"Right Button Up")
    EndSelect     
Until Event = #PB_Event_CloseWindow

Re: Windows API mouse commands no longer work

Posted: Sun Jan 27, 2013 9:27 am
by netmaestro
The buttonup events can be identified by the appropriate click events in the PB event loop:

Code: Select all

;        Windows_Message__Mouse_Events__v2.pb

;        Post subject: Windows API mouse commands no longer work
;        http://www.purebasic.fr/english/viewtopic.php?f=13&t=53112

OpenWindow(0, 0, 0, 800, 600, "Test",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
   
StartDrawing(WindowOutput(0))
    Box(0,0,800,600,RGB(0,0,0))
StopDrawing()

Repeat
 
  Event= WaitWindowEvent()   
  Debug event
    Select event
    Case #PB_Event_CloseWindow
         End
    Case #WM_LBUTTONDOWN
         SetWindowTitle(0,"Left Button Down")
    Case #PB_Event_LeftClick
         SetWindowTitle(0,"Left Button Up")
    Case #PB_Event_LeftDoubleClick
         SetWindowTitle(0,"Left Button DoubeClick")
    Case #WM_RBUTTONDOWN
         SetWindowTitle(0,"Right Button Down")
    Case #PB_Event_RightClick
         SetWindowTitle(0,"Right Button Up")
    EndSelect     
  Until Event = #PB_Event_CloseWindow
  
As seen in this code, the only events you need to use WM_ messages for are the buttondown events. Everything else is available through native events.

Re: Windows API mouse commands no longer work

Posted: Sun Jan 27, 2013 10:30 am
by VB6_to_PBx
netmaestro, thank you for the clarification !

(luis's ) type Code below seems to work in all the versions from 5.0 to latest 5.10Beta's

Code: Select all


;        Windows_Message__Mouse_Events__v3.pb

;        Post subject: Windows API mouse commands no longer work
;        http://www.purebasic.fr/english/viewtopic.php?f=13&t=53112


Procedure wc (hWnd, uMsg, wParam, lParam)   
    Select uMsg
    Case #WM_LBUTTONDOWN   : SetWindowTitle(0,"Left Button Down")
    Case #WM_LBUTTONUP     : SetWindowTitle(0,"Left Button Up")
    Case #WM_LBUTTONDBLCLK : SetWindowTitle(0,"Left Button DoubleClick")
    Case #WM_RBUTTONDOWN   : SetWindowTitle(0,"Right Button Down")
    Case #WM_RBUTTONUP     : SetWindowTitle(0,"Right Button Up")
    Case #WM_RBUTTONDBLCLK : SetWindowTitle(0,"Right Button DoubleClick")
    EndSelect     

    ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

OpenWindow(0, 0, 0, 800, 600, "Test",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
     
SetWindowCallback(@wc())

Repeat : Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow



Re: Windows API mouse commands no longer work

Posted: Tue Jun 04, 2013 7:23 am
by aliza12
Hi Guys
1st Type the code type Code below seems to work in all the versions from 5.0 to latest 5.10Beta's

Code:

; Windows_Message__Mouse_Events__v3.pb

; Post subject: Windows API mouse commands no longer work
; http://www.purebasic.fr/english/viewtop ... 13&t=53112


Procedure wc (hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_LBUTTONDOWN : SetWindowTitle(0,"Left Button Down")
Case #WM_LBUTTONUP : SetWindowTitle(0,"Left Button Up")
Case #WM_LBUTTONDBLCLK : SetWindowTitle(0,"Left Button DoubleClick")
Case #WM_RBUTTONDOWN : SetWindowTitle(0,"Right Button Down")
Case #WM_RBUTTONUP : SetWindowTitle(0,"Right Button Up")
Case #WM_RBUTTONDBLCLK : SetWindowTitle(0,"Right Button DoubleClick")
EndSelect

ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure

OpenWindow(0, 0, 0, 800, 600, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered )

SetWindowCallback(@wc())

Repeat : Event = WaitWindowEvent() : Until Event = #PB_Event_CloseWindow