Page 2 of 2
Re: [5.11] #WM_LBUTTONUP event on window disappear
Posted: Fri Apr 26, 2013 11:59 am
by luis
dobro wrote:
at this time why the constants :
#WM_LBUTTONDOWN
#WM_LBUTTONDBLCLK
#WM_RBUTTONDOWN
#WM_MOUSEWHEEL
ect ...
are recognized by Purebasic?
and why just # WM_LBUTTONUP
do not be?
It's not so hard. Pay attention:
The #WM_* constants are defined in PB to be usable with the API. The same API you already find in the residents for your convenience. So you don't have to manually import them.
Again for your convenience you have API constants, and a lot of structures, already defined in the residents, to be used with those API.
So when you say "recognized" you should say "defined".
They are defined. Even #WM_LBUTTONUP is still currently defined in PB. It's not vanished.
You can perfectly use it where it's supposed to be used it. In a callback, in a API function as sendmessage_(), in your manual subclassing of a window, etc.
Now, some of those messages ( S O M E is the keyword) are also returned, and not D O C U M E N T E D as valid return values by WindowEvent(). You have no right to suppose for them to be returned by WindowEvent(). Is that clear enough ? You want to use it anyway ? It's up to you.
One of them is no more returned in a newer version of PB ? Find another way (the proper way) because it was entirely your fault to rely on them.
Re: [5.11] #WM_LBUTTONUP event on window disappear
Posted: Fri Apr 26, 2013 12:03 pm
by dobro
Thanks !
Fred must be added to the Doc,
"the use of API, and their constant, is at our risk and peril"
This code was too simple
Code: Select all
; Auteur : Le Soldat Inconnu, Fred
; Version de PB : 3.90
;
; Explication du programme :
; Détection des différents état de la souris - Appuyer sur le bouton gauche, relacher le bouton gauche, double clic, etc ...
#WM_MOUSEWHEEL = $20A
#WHEEL_DELTA = 120
#text=1
If OpenWindow(0, 0, 0, 200, 200, "Souris",#PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
SetClassLong_(WindowID(0), #GCL_STYLE, GetClassLong_(WindowID(0), #GCL_STYLE) | #CS_DBLCLKS) ; Active la gestion du double clic
CreateImage(0, 200, 100)
StartDrawing(ImageOutput(0))
DrawingMode(1)
FrontColor(RGB(255, 255, 255))
DrawText(5,5,"Marche pas sur l'image :")
DrawText(5,20,"Bouton gauche appuyé")
DrawText(5,35,"Double clic gauche")
StopDrawing()
ImageGadget(0, 0, 0, 200, 100, ImageID(0))
SetWindowLong_(GadgetID(0), #GWL_STYLE, GetWindowLong_(GadgetID(0), #GWL_STYLE) & ~#SS_NOTIFY)
TextGadget(#text, 1, 150, 200, 50, "appuis touche souris")
Repeat
Event = WaitWindowEvent()
If Event = #WM_LBUTTONDOWN
SetGadgetText(#text, "Bouton gauche appuyé")
ElseIf Event = #WM_LBUTTONUP
SetGadgetText(#text,"Bouton gauche relaché") ; < ------------------------- Bug !!! no effect
ElseIf Event = #WM_LBUTTONDBLCLK
SetGadgetText(#text,"Double clic gauche")
ElseIf Event = #WM_RBUTTONDOWN
SetGadgetText(#text,"Bouton droit appuyé")
ElseIf Event = #WM_RBUTTONUP
SetGadgetText(#text,"Bouton droit relaché") ; < ------------------------- Bug !!! no effect
ElseIf Event = #WM_RBUTTONDBLCLK
SetGadgetText(#text,"Double clic droit")
ElseIf Event = #WM_MBUTTONDOWN
SetGadgetText(#text,"Bouton du milieu appuyé")
ElseIf Event = #WM_MBUTTONUP
SetGadgetText(#text,"Bouton du milieu relaché")
ElseIf Event = #WM_MBUTTONDBLCLK
SetGadgetText(#text,"Double clic du milieu")
ElseIf Event = #WM_MOUSEWHEEL
Molette.l = -(EventwParam() >> 16) / #WHEEL_DELTA
If Molette > 0
SetGadgetText(#text,"Molette en avant de " + Str(Molette))
ElseIf Molette < 0
SetGadgetText(#text,"Molette en arrière de " + Str(Molette))
EndIf
ElseIf Event = #PB_Event_Gadget
Select EventGadget()
Case 0
Select EventType()
Case #PB_EventType_LeftClick
SetGadgetText(#text,"Gadget : Bouton gauche appuyé")
Case #PB_EventType_LeftDoubleClick
SetGadgetText(#text,"Gadget : Double clic gauche")
EndSelect
EndSelect
EndIf
Until Event = #WM_CLOSE
EndIf
arf !!
miracle :: #WM_MBUTTONUP
Work !!! yeeeehaaaa !
Luckily, "For next" working yet

Re: [5.11] #WM_LBUTTONUP event on window disappear
Posted: Fri Apr 26, 2013 12:38 pm
by luis
dobro wrote:
Fred must be added to the Doc,
That would be handy, to have a copy of Fred inside the docs !
dobro wrote:
"the use of API, and their constant, is at our risk and peril"
Along with "your programs may contains bugs".
dobro wrote:
This code was too simple
It can be changed to work the same way with the messages processed inside the main loop as it is now in 90 secs using PostEvent(), five minutes if you are not yet familiar with it.
EDIT: No, a little more than 90 seconds because I just noticed you also use Event*Param(), ALSO undocumented.
So you need to pass the appropriate wparam, lparam through PostEvent() too.
Re: [5.11] #WM_LBUTTONUP event on window disappear
Posted: Fri Apr 26, 2013 1:14 pm
by MachineCode
I meant show me in the manual for the WindowEvent() command where #WM_LBUTTONUP is supported. It's not. Look:
PureBasic Manual wrote: #PB_Event_Menu : a menu has been selected
#PB_Event_Gadget : a gadget has been pushed
#PB_Event_SysTray : an icon in the systray zone was clicked
#PB_Event_Timer : a timer has reached its timeout
#PB_Event_CloseWindow : the window close gadget has been pushed
#PB_Event_Repaint : the window content has been destroyed and must be repainted (useful for 2D graphics operations)
#PB_Event_SizeWindow : the window has been resized
#PB_Event_MoveWindow : the window has been moved
#PB_Event_MinimizeWindow : the window has been minimized
#PB_Event_MaximizeWindow : the window has been maximized
#PB_Event_RestoreWindow : the window has been restored to normal size (either from a minimum or maximum size)
#PB_Event_ActivateWindow : the window has been activated (got the focus)
#PB_Event_DeactivateWindow: the window has been deactivated (lost the focus)
#PB_Event_WindowDrop : a Drag & Drop operation was finished on a window
#PB_Event_GadgetDrop : a Drag & Drop operation was finished on a gadget
#PB_Event_RightClick : a right mouse button click has occurred on the window. This can be useful to display a popup menu
#PB_Event_LeftClick : a left mouse button click has occurred on the window
#PB_Event_LeftDoubleClick : a left mouse button double-click has occurred on the window
I don't see any #WM_* constants listed there. Do you?
Re: [5.11] #WM_LBUTTONUP event on window disappear
Posted: Fri Apr 26, 2013 3:02 pm
by Demivec
Try using these constants instead:
Code: Select all
;Unsupported PureBasic Window Message constants for v5.11
#UPB_WM_RBUTTONUP = 13111
#UPB_WM_LBUTTONUP = 13112
#UPB_WM_LBUTTONDBLCLK = 13113

Re: [5.11] #WM_LBUTTONUP event on window disappear
Posted: Fri Apr 26, 2013 3:03 pm
by dobro
Fred explained the French Forum need to use Constants # Wm ****
only in a callback!
for me the problem is solved
Thank you to all
Re: [5.11] #WM_LBUTTONUP event on window disappear
Posted: Fri Apr 26, 2013 5:10 pm
by Bisonte
dobro wrote:Fred explained the French Forum need to use Constants # Wm ****
only in a callback!
for me the problem is solved
Thank you to all
Thats is what all the people here said to you

Re: [5.11] #WM_LBUTTONUP event on window disappear
Posted: Fri Apr 26, 2013 11:15 pm
by luis
This is a possible conversion using a callback, keeping the message processing inside the original loop (in this simple case probably not really much useful).
Code: Select all
; Auteur : Le Soldat Inconnu, Fred
; Version de PB : 3.90
;
; Explication du programme :
; Détection des différents état de la souris - Appuyer sur le bouton gauche, relacher le bouton gauche, double clic, etc ...
; updated to 5.11 by someone else
#WM_MOUSEWHEEL = $20A
#WHEEL_DELTA = 120
#text=1
Enumeration #PB_Event_FirstCustomValue
#My_Event_LeftClick_Down
#My_Event_LeftClick_Up
#My_Event_MiddleClick_Down
#My_Event_MiddleClick_Up
#My_Event_RightClick_Down
#My_Event_RightClick_Up
#My_Event_LeftDblClick
#My_Event_MiddleDblClick
#My_Event_RightDblClick
#My_Event_MouseWheel
EndEnumeration
Procedure wc (hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_LBUTTONDOWN
PostEvent(#My_Event_LeftClick_Down)
Case #WM_LBUTTONUP
PostEvent(#My_Event_LeftClick_Up)
Case #WM_MBUTTONDOWN
PostEvent(#My_Event_MiddleClick_Down)
Case #WM_MBUTTONUP
PostEvent(#My_Event_MiddleClick_Up)
Case #WM_RBUTTONDOWN
PostEvent(#My_Event_RightClick_Down)
Case #WM_RBUTTONUP
PostEvent(#My_Event_RightClick_Up)
Case #WM_LBUTTONDBLCLK
PostEvent(#My_Event_LeftDblClick)
Case #WM_MBUTTONDBLCLK
PostEvent(#My_Event_MiddleDblClick)
Case #WM_RBUTTONDBLCLK
PostEvent(#My_Event_RightDblClick)
Case #WM_MOUSEWHEEL
PostEvent(#My_Event_MouseWheel, 0, 0, 0, wParam) ; merge wParam and lParam if you need both
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
If OpenWindow(0, 0, 0, 200, 200, "Souris",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowCallback(@wc())
; is this needed ?
; SetClassLong_(WindowID(0), #GCL_STYLE, GetClassLong_(WindowID(0), #GCL_STYLE) | #CS_DBLCLKS) ; Active la gestion du double clic
CreateImage(0, 200, 100)
StartDrawing(ImageOutput(0))
DrawingMode(1)
FrontColor(RGB(255, 255, 255))
DrawText(5,5,"Marche pas sur l'image :")
DrawText(5,20,"Bouton gauche appuyé")
DrawText(5,35,"Double clic gauche")
StopDrawing()
ImageGadget(0, 0, 0, 200, 100, ImageID(0))
; is this needed ?
; SetWindowLong_(GadgetID(0), #GWL_STYLE, GetWindowLong_(GadgetID(0), #GWL_STYLE) & ~#SS_NOTIFY)
TextGadget(#text, 1, 150, 200, 50, "appuis touche souris")
Repeat
Event = WaitWindowEvent()
If Event = #My_Event_LeftClick_Down
SetGadgetText(#text, "Bouton gauche appuyé")
ElseIf Event = #My_Event_LeftClick_Up
SetGadgetText(#text,"Bouton gauche relaché")
ElseIf Event = #My_Event_LeftDblClick
SetGadgetText(#text,"Double clic gauche")
ElseIf Event = #My_Event_RightClick_Down
SetGadgetText(#text,"Bouton droit appuyé")
ElseIf Event = #My_Event_RightClick_Up
SetGadgetText(#text,"Bouton droit relaché")
ElseIf Event = #My_Event_RightDblClick
SetGadgetText(#text,"Double clic droit")
ElseIf Event = #My_Event_MiddleClick_Down
SetGadgetText(#text,"Bouton du milieu appuyé")
ElseIf Event = #My_Event_MiddleClick_Up
SetGadgetText(#text,"Bouton du milieu relaché")
ElseIf Event = #My_Event_MiddleDblClick
SetGadgetText(#text,"Double clic du milieu")
ElseIf Event = #My_Event_MouseWheel
Molette.l = -(EventData() >> 16) / #WHEEL_DELTA
If Molette > 0
SetGadgetText(#text,"Molette en avant de " + Str(Molette))
ElseIf Molette < 0
SetGadgetText(#text,"Molette en arrière de " + Str(Molette))
EndIf
ElseIf Event = #PB_Event_Gadget
Select EventGadget()
Case 0
Select EventType()
Case #PB_EventType_LeftClick
SetGadgetText(#text,"Gadget : Bouton gauche appuyé")
Case #PB_EventType_LeftDoubleClick
SetGadgetText(#text,"Gadget : Double clic gauche")
EndSelect
EndSelect
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Re: [5.11] #WM_LBUTTONUP event on window disappear
Posted: Sat Apr 27, 2013 6:41 pm
by Le Soldat Inconnu
So now, may be PB can support event up and down on left, right, on middle mouse button, no ? because we use often

Re: [5.11] #WM_LBUTTONUP event on window disappear
Posted: Sun Mar 16, 2014 1:43 pm
by mestnyi
In Linux, what to do? Why Linux does not have such events?