Page 1 of 1
5.30 SendMessageCallback don't work
Posted: Tue Aug 05, 2014 8:40 pm
by bizdon
code:
Code: Select all
Procedure WndProc(hWnd,msg,wParam,lparam)
If hWnd = WindowID(0)
Select msg
Case #WM_LBUTTONDOWN
ReleaseCapture_()
SendMessage_(hWnd,#WM_SYSCOMMAND,#SC_MOVE|#HTCAPTION,0)
Case #WM_COMMAND
If wParam= 1+#PB_EventType_LeftClick<<16
SendMessageCallback_(hWnd,#PB_Event_CloseWindow,0,0,@WndProc(),0)
EndIf
EndSelect
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0,0,0,300,300,"qwe",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ButtonGadget(1,220,260,55,25,"exit")
SetWindowCallback(@WndProc())
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
when I click the button "exit" the program is not completed. In
v5.20 and earlier versions, everything worked. Why?
Thank you!
Re: 5.30 SendMessageCallback don't work
Posted: Tue Aug 05, 2014 11:09 pm
by Fred
I don't know what you want to do, but you should use PostEvent() if you want to send a PB event to the queue.
Re: 5.30 SendMessageCallback don't work
Posted: Wed Aug 06, 2014 1:51 am
by bizdon
Yes, it works: PostEvent(#PB_Event_CloseWindow)
But only in v5.30! In v5.20 and earlier versions don't work.
Maybe I misused the function SendMessageCallback...
It is necessary to use PostMessage_(hWnd,#PB_Event_CloseWindow,0,0) - it works in all versions
The purpose of this reception is working with functions PB and easy access to the message queue window
Re: 5.30 SendMessageCallback don't work
Posted: Wed Aug 06, 2014 11:03 am
by bizdon
Sorry for my English.
Code: Select all
Procedure WndProc(hWnd,msg,wParam,lparam)
If hWnd = WindowID(0)
Select msg
Case #WM_LBUTTONDOWN
ReleaseCapture_()
SendMessage_(hWnd,#WM_SYSCOMMAND,#SC_MOVE|#HTCAPTION,0)
Case #WM_COMMAND
If wParam= 1+#PB_EventType_LeftClick<<16
; PostMessage_(WindowID(0),#PB_Event_CloseWindow,0,0) ;WORKS!
; SendMessage_(WindowID(0),#PB_Event_CloseWindow,0,0) ;DOES Not WORK!
; SendMessageCallback_(WindowID(0),#PB_Event_CloseWindow,0,0,@WndProc(),0) ;DOES Not WORK!
; SendNotifyMessage_(WindowID(0),#PB_Event_CloseWindow,0,0) ;DOES Not WORK!
EndIf
EndSelect
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0,0,0,300,300,"qwe",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ButtonGadget(1,220,260,55,25,"exit")
SetWindowCallback(@WndProc())
Repeat:
Event=WaitWindowEvent()
gadget=EventGadget()
If Event=#PB_Event_Gadget And gadget=1
PostMessage_(WindowID(0),#PB_Event_CloseWindow,0,0) ;WORKS!
; SendMessage_(WindowID(0),#PB_Event_CloseWindow,0,0) ;DOES Not WORK!
; SendMessageCallback_(WindowID(0),#PB_Event_CloseWindow,0,0,@WndProc(),0) ;;DOES Not WORK!
; SendNotifyMessage_(WindowID(0),#PB_Event_CloseWindow,0,0) ;;DOES Not WORK!
EndIf
Until Event=#PB_Event_CloseWindow
I think in at v5.30/5.22 don't work asynchronous messages in the queue. In
v5.20 and earlier versions everything is fine.
Re: 5.30 SendMessageCallback don't work
Posted: Wed Aug 06, 2014 11:05 am
by Fred
Once again, you should not assume than using an API to send private PB message will always work or be future proof. If you need such, the only reliable way is to use PostEvent().
Re: 5.30 SendMessageCallback don't work
Posted: Wed Aug 06, 2014 3:58 pm
by Bisonte
Fred means :
If you use API functions, you have to use API - Events !!! (in your case above #WM_CLOSE)
If you use PB Events, you have to use PostEvent()
Re: 5.30 SendMessageCallback don't work
Posted: Wed Aug 06, 2014 4:23 pm
by bizdon
Bisonte
Thank you! Actually, everything is simple. But these changes occurred from version 5.20. In the certificate is not written. I did not realize it himself.