Page 1 of 2

[5.11] #WM_LBUTTONUP event on window disappear

Posted: Thu Apr 25, 2013 1:36 am
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

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Thu Apr 25, 2013 1:40 am
by skywalk
Yeah, someone mentioned this is not a bug, since you can use a windows callback to properly access undocumented messages.

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Thu Apr 25, 2013 8:31 am
by STARGÅTE

Code: Select all

   Select Event
         
      Case #WM_LBUTTONDOWN
         Debug "pressed"
      Case #PB_Event_LeftClick
         Debug "released"
   EndSelect

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Thu Apr 25, 2013 11:28 am
by luis

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Thu Apr 25, 2013 12:07 pm
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.

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Thu Apr 25, 2013 12:19 pm
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.

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Thu Apr 25, 2013 1:14 pm
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. :)

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Thu Apr 25, 2013 2:16 pm
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...

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Fri Apr 26, 2013 11:13 am
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:

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Fri Apr 26, 2013 11:20 am
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.

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Fri Apr 26, 2013 11:21 am
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 ;)

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Fri Apr 26, 2013 11:30 am
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:

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Fri Apr 26, 2013 11:48 am
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.

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Fri Apr 26, 2013 11:51 am
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! ;)

Re: [5.11] #WM_LBUTTONUP event on window disappear

Posted: Fri Apr 26, 2013 11:57 am
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.