[5.11] #WM_LBUTTONUP event on window disappear

Just starting out? Need help? Post your questions and find answers here.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post 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.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post by dobro »

Thanks !

Fred must be added to the Doc,
"the use of API, and their constant, is at our risk and peril" :lol: :lol:

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
:lol: :lol: :lol:
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post 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" :lol: :lol:
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.
"Have you tried turning it off and on again ?"
A little PureBasic review
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post 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?
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post 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
:)
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post 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
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
Bisonte
Addict
Addict
Posts: 1305
Joined: Tue Oct 09, 2007 2:15 am

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post 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 :mrgreen:
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post 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
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Le Soldat Inconnu
Enthusiast
Enthusiast
Posts: 306
Joined: Wed Jul 09, 2003 11:33 am
Location: France

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post 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 :mrgreen:
LSI
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post by mestnyi »

In Linux, what to do? Why Linux does not have such events?
Post Reply