[5.11] #WM_LBUTTONUP event on window disappear

Just starting out? Need help? Post your questions and find answers here.
User avatar
Le Soldat Inconnu
Enthusiast
Enthusiast
Posts: 306
Joined: Wed Jul 09, 2003 11:33 am
Location: France

[5.11] #WM_LBUTTONUP event on window disappear

Post by Le Soldat Inconnu »

Hi,

With last version of PB (5.11, download yesterday), the event #WM_LBUTTONUP disappear when i click on window. And i need it for a lot of my program (Full skinned window)
For this moment i back to 5.0, no problem with this version.
I just get #WM_LBUTTONDOWN but no #WM_LBUTTONUP

Code to try : Compile with debugger

Code: Select all

If OpenWindow(0, 0, 0, 500, 300, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget) = 0
	End
EndIf

Repeat
	Event = WaitWindowEvent()
	
	Select Event
			
		Case #WM_LBUTTONDOWN
			Debug "pressed"
		Case #WM_LBUTTONUP
			Debug "released"
	EndSelect
	
Until Event = #PB_Event_CloseWindow
LSI
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post by skywalk »

Yeah, someone mentioned this is not a bug, since you can use a windows callback to properly access undocumented messages.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post by STARGÅTE »

Code: Select all

   Select Event
         
      Case #WM_LBUTTONDOWN
         Debug "pressed"
      Case #PB_Event_LeftClick
         Debug "released"
   EndSelect
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
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 »

"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 »

First point :
I can't use CallBack because my code is a library (Build with TailBite)

And if it' the same, why it doesn't work like #WM_Close = #PB_Event_Close_Window
Why #WM_LBUTTONUP <> #PB_Event_LeftClick ?

I disagree with you, sorry. For me, it's a bug.
LSI
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post by ts-soft »

Le Soldat Inconnu wrote:I disagree with you, sorry. For me, it's a bug.
This can't be a bug, API-Events not official supported in PB-Event-Loop!
If it work, like older versions, is it okay, but if it not work, it isn't a bug.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
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 »

Le Soldat Inconnu wrote:I disagree with you, sorry. For me, it's a bug.
Show me where in the manual it says that #WM_LBUTTONUP is supported. Then I'll agree it's a bug. :)
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
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 »

Le Soldat Inconnu wrote:First point :
I can't use CallBack because my code is a library (Build with TailBite)
Why there is a problem with callbacks ? I use it...
(e.g. a Canvasgadget with Callback to draw automatic hoover, selected etc.
to handle it like a normal PB ButtonGadget.)

Edit : I made a small example - "tailbited" with 1.49 and PB5.11x86 Windows
The Lib:

Code: Select all

EnableExplicit
;
#mUI_PROP_DEFCALLBACK = "mUI:DefCallBack"
;
Enumeration #PB_Event_FirstCustomValue
  #mUI_Event_LButtonDown
  #mUI_Event_MButtonDown
  #mUI_Event_RButtonDown
  #mUI_Event_LButtonUp
  #mUI_Event_MButtonUp
  #mUI_Event_RButtonUp
EndEnumeration
;
Structure mUI_callbackdata_struct
  Window.i
  OldProc.i
  ExtraData.i
EndStructure
;
ProcedureDLL mUI_TestLibrary_Init()
  ;Ressources
EndProcedure
ProcedureDLL mUI_TestLibrary_End()
  ;FreeRessources
EndProcedure
; private
Procedure private_mUI_WindowCallBack(hWnd, uMsg, wParam, lParam)
  
  Protected OldProc
  Protected *p.mUI_callbackdata_struct
  
  *p = GetProp_(hWnd, #mUI_PROP_DEFCALLBACK)
  If Not *p : ProcedureReturn 0 : EndIf
  
  OldProc = *p\OldProc
  
  Select uMsg
    Case #WM_NCDESTROY
      RemoveProp_(hWnd, #mUI_PROP_DEFCALLBACK)
      FreeMemory(*p)
      
    Case #WM_LBUTTONDOWN
      PostEvent(#mUI_Event_LButtonDown, *p\Window, 0)
    Case #WM_MBUTTONDOWN
      PostEvent(#mUI_Event_MButtonDown, *p\Window, 0)
    Case #WM_RBUTTONDOWN
      PostEvent(#mUI_Event_RButtonDown, *p\Window, 0)
    Case #WM_LBUTTONUP
      PostEvent(#mUI_Event_LButtonUp, *p\Window, 0)
    Case #WM_MBUTTONUP
      PostEvent(#mUI_Event_MButtonUp, *p\Window, 0)
    Case #WM_RBUTTONUP
      PostEvent(#mUI_Event_RButtonUp, *p\Window, 0)
      
  EndSelect
  
  If OldProc
    ProcedureReturn CallWindowProc_(OldProc, hWnd, uMsg, wParam, lParam)
  Else
    ProcedureReturn 0
  EndIf
  
EndProcedure
Procedure private_mUI_RegisterWindow(Window)
  
  Protected *p.mUI_callbackdata_struct = AllocateMemory(SizeOf(mUI_callbackdata_struct))
  
  If Not *p : ProcedureReturn #False : EndIf
  InitializeStructure(*p, mUI_callbackdata_struct)
  
  If IsWindow(Window)
    *p\OldProc    = SetWindowLongPtr_(WindowID(Window), #GWLP_WNDPROC, @private_mUI_WindowCallBack())
    *p\Window     = Window
    *p\ExtraData  = 0
    SetProp_(WindowID(Window), #mUI_PROP_DEFCALLBACK, *p)
    ProcedureReturn *p
  EndIf
  
  FreeMemory(*p)
  
  ProcedureReturn #False
  
EndProcedure
Procedure private_mUI_OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, Flags = #PB_Window_SystemMenu, ParentID = 0)
  
  Protected Result = #False
  
  If IsWindow_(ParentID)
    Result = OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, Flags, ParentID)
  Else
    Result = OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, Flags)
  EndIf
  
  If Window = #PB_Any : Window = Result : EndIf
  If IsWindow(Window)
    private_mUI_RegisterWindow(Window)
  EndIf
  
  ProcedureReturn Result
  
EndProcedure
; public
ProcedureDLL PmUI_OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$)
  ProcedureReturn private_mUI_OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, #PB_Window_SystemMenu, 0)
EndProcedure
ProcedureDLL PmUI_OpenWindow2(Window, x, y, InnerWidth, InnerHeight, Title$, Flags)
  ProcedureReturn private_mUI_OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, Flags, 0)
EndProcedure
ProcedureDLL PmUI_OpenWindow3(Window, x, y, InnerWidth, InnerHeight, Title$, Flags, ParentID)
  ProcedureReturn private_mUI_OpenWindow(Window, x, y, InnerWidth, InnerHeight, Title$, Flags, ParentID)
EndProcedure
The Resident

Code: Select all

Enumeration #PB_Event_FirstCustomValue
  #mUI_Event_LButtonDown
  #mUI_Event_MButtonDown
  #mUI_Event_RButtonDown
  #mUI_Event_LButtonUp
  #mUI_Event_MButtonUp
  #mUI_Event_RButtonUp
EndEnumeration
;
Macro OpenWindow
  PmUI_OpenWindow
EndMacro
the example

Code: Select all

OpenWindow(0,200,300,800,600,"TestWindow")

ButtonGadget(0,10,10,100,30, "It works")

Repeat
  Event = WaitWindowEvent(25)
  
  Select Event
    Case #mUI_Event_LButtonDown
      Debug "WM_LBUTTONDOWN"
      
    Case #mUI_Event_LButtonUp
      Debug "WM_LBUTTONUP"
      
    Case #PB_Event_Gadget
      If EventGadget() = 0
        Debug "ButtonGadget"
      EndIf
      
    Case #PB_Event_CloseWindow
      Quit = 1
      
  EndSelect
  
Until Quit > 0
And with the macro in the residentfile, a user that use the lib, don't remark it...
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
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 »

MachineCode wrote:
Le Soldat Inconnu wrote:I disagree with you, sorry. For me, it's a bug.
Show me where in the manual it says that #WM_LBUTTONUP is supported. Then I'll agree it's a bug. :)
The main features of PureBasic

- Huge set of internal commands (1100+) to quickly and easily build any application or game
- All BASIC keywords are supported
- Very fast compiler which creates highly optimized executables
- No external DLLs, runtime interpreter or anything else required when creating executables
- Procedure support for structured programming with local and global variables
- Full unicode support
- Access to full OS API for advanced programmers
- Easy but very fast 2D game support through dedicated libraries (DirectX, SDL, ...)
- Easy and high quality 3D support based on OGRE
- Optimal use of the available hardware by using highly optimized (assembly) commands
- Source code is portable between AmigaOS, Windows, MacOS X and Linux
- Dedicated editor and development environment
- Powerful integrated debugger and profiler to easily trace and analyze code
it is written in the Doc Purebasic that is compatible with the Windows API
gold, the consante : "#WM_LBUTTONUP" Part of the windows api !!! --->

http://msdn.microsoft.com/en-us/library ... 85%29.aspx


If you do nothing else as arguments, it is better to go fishing ;)

there is always a wise guy to give a solution to avoid a lack or a bug PureBasic
you can also go and use another language! :twisted:
Last edited by dobro on Fri Apr 26, 2013 11:23 am, edited 2 times in total.
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: it is written in the Doc Purebasic that is compatible with the Windows API
gold, the consante Part of the windows api
Don't be absurd.
help wrote: The Win32 API is fully supported as if they were BASIC keywords
This simply means you can invoke the api defined in the residents as they were PB commands, without the need to manually import them. Doesn't mean you can go around using api constant randomly as parameters or return values for pb commands.

Happy fishing.
"Have you tried turning it off and on again ?"
A little PureBasic review
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: - Access to full OS API for advanced programmers
Purebasic - Help (F1) : SetWindowCallback wrote: Syntax

SetWindowCallback(@ProcedureName() [, #Window])

Description

For experienced programmers only. It's only supported on Microsoft Windows OS.
So you have it ;)
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
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 »

luis wrote: This simply means you can invoke the api defined in the residents as they were PB commands, without the need to manually import them. Doesn't mean you can go around using api constant randomly as parameters or return values for pb commands.

Happy fishing.
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?

that have no meaning! :?

( Fred quand tu veux tu nous éclaire sur ce Sujet !! ) :)

So you have it
do you not worried for me, young man :wink:
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post by Little John »

As Bisonte wrote, you can use any Windows API constants in a callback function, so they are supported.
dobro wrote:at this time why the constants :

#WM_LBUTTONDOWN
#WM_LBUTTONDBLCLK
#WM_RBUTTONDOWN
#WM_MOUSEWHEEL

ect ...

are recognized by Purebasic?

and just why # WM_LBUTTONUP
do not be?
Do you have an idea how many Windows API constants exist? Many of them are not supported by PB outside of a callback function. Yes, you can use some constants outside of a callback function, but there was and is no official list of them. So this can change at any time, as you just observed.
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 »

Little John wrote: Do you have an idea how many Windows API constants exist? Many of them are not supported by PB outside of a callback function. Yes, you can use some constants outside of a callback function, but there was and is no official list of them. So this can change at any time, as you just observed.

the problem is that the constant #WM_LBUTTONUP

was recognized by PureBasic, up to version 5.00!

and many of the old code uses! ;)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: [5.11] #WM_LBUTTONUP event on window disappear

Post by Little John »

dobro wrote:the problem is that the constant #WM_LBUTTONUP

was recognized by PureBasic, up to version 5.00!

and many of the old code uses! ;)
Yes of course, I know.
Sorry, but I think that's just your risk when using something that is not officially documented.
Post Reply