Hi does anybody know if I can add an own eventloop to a child window.
I mean like a Containergadget with it's own Eventllop.
Could someone please tell me if something like that is possible or not.
Child Eventloop
Child Eventloop
Apart from that Mrs Lincoln, how was the show?
-
localmotion34
- Enthusiast

- Posts: 665
- Joined: Fri Sep 12, 2003 10:40 pm
- Location: Tallahassee, Florida
use a subclass procedure catching the #wm_command or some other message. i have written tons of code on how to subclass, just find my examples.
compare lparam and wparam to your gadgetid's, compare x and y locations of a mouse, detect and process left and right button clicks.
compare lparam and wparam to your gadgetid's, compare x and y locations of a mouse, detect and process left and right button clicks.
WM_COMMAND
wNotifyCode = HIWORD(wParam); // notification code
wID = LOWORD(wParam); // item, control, or accelerator identifier
hwndCtl = (HWND) lParam; // handle of control
The WM_COMMAND message is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.
Parameters
wNotifyCode
Value of the high-order word of wParam. Specifies the notification code if the message is from a control. If the message is from an accelerator, this parameter is 1. If the message is from a menu, this parameter is 0.
wID
Value of the low-order word of wParam. Specifies the identifier of the menu item, control, or accelerator.
hwndCtl
Value of lParam. Identifies the control sending the message if the message is from a control. Otherwise, this parameter is NULL.
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
- Fluid Byte
- Addict

- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Yeah, sub-classing is the way. Here's an example:
Code: Select all
Global lpPrevWndFunc.l
Procedure WndChildProc(hwnd.l,uMsg.l,wParam.l,lParam.l)
Select uMsg
Case #WM_LBUTTONDOWN
Debug "Snatched window event!"
EndSelect
ProcedureReturn CallWindowProc_(lpPrevWndFunc,hwnd,uMsg,wParam,lParam)
EndProcedure
OpenWindow(0,0,0,320,240,"untitled",#WS_OVERLAPPEDWINDOW | 1)
CreateGadgetList(WindowID(0))
*hwndCont = ContainerGadget(0,5,5,310,230,2)
lpPrevWndFunc = SetWindowLong_(*hwndCont,#GWL_WNDPROC,@WndChildProc())
While WaitWindowEvent() ! 16 : WendWindows 10 Pro, 64-Bit / Whose Hoff is it anyway?
as fred said before (do not remember which post),
events must be processed in the same thread of the one in which we have created the window. it's a windows feature.
but if someone can confirm...
events must be processed in the same thread of the one in which we have created the window. it's a windows feature.
but if someone can confirm...
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
-
localmotion34
- Enthusiast

- Posts: 665
- Joined: Fri Sep 12, 2003 10:40 pm
- Location: Tallahassee, Florida
Yes it does work, just with subclassing. It's called DOUBLE SUBCLASSING.freak wrote:It will not work because PB events are always posted up to the main window.
Your eventloop for the container will not receive any events.
and heres the example:
Code: Select all
Global oldproc.l
Procedure notpossibleproc(hwnd,msg,wParam,lParam)
Select msg
Case #WM_COMMAND
Debug "The control I got the message from is" + Space(1) +Str(lParam)
Debug "the gadgetid of button 1 is" + Space(1) + Str(GadgetID(1))
Debug "I just Punk'd the eventloop"
ProcedureReturn 0 ;don't let the eventloop get this message
;alternatively, you can let this message pass to the eventloop
EndSelect
ProcedureReturn DefWindowProc_(hwnd,msg,wParam,lParam)
EndProcedure
Procedure letitpassproc(hwnd,msg,wParam,lParam)
Select msg
;trap anyother messages you want here, EXCEPT the #wm_command
EndSelect
ProcedureReturn CallWindowProc_(oldproc,hwnd,msg,wParam,lParam)
EndProcedure
If OpenWindow(0, 869, 108, 237, 471, "Robbing and Stealing", #PB_Window_SystemMenu | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(0))
ContainerGadget(200,20,20,150,90,#PB_Container_Raised)
oldproc=GetWindowLong_(GadgetID(200), #GWL_WNDPROC)
ButtonGadget(1, 10, 15, 80, 24, "Button 1")
oldproc=SetWindowLong_(GadgetID(200),#GWL_WNDPROC,@notpossibleproc())
CloseGadgetList()
CheckBoxGadget(2,10,150,180,20,"Allow Container Events to Pass")
EndIf
EndIf
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Debug "PB event loop got the message!!!"
Debug "Localmotion34 Rocks!!!"
Case 2
State=GetGadgetState(2)
Select State
Case 0
SetWindowLong_(GadgetID(200),#GWL_WNDPROC,@notpossibleproc())
Case 1
SetWindowLong_(GadgetID(200),#GWL_WNDPROC,@letitpassproc())
EndSelect
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
End
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
