ok, so you create a window in the main program and setwindowcallback() for that window. now lets say you are creating a custom gadget in a NEW THREAD so that the custom gadget can have its own event loop. can you setwindowcallback() for the custom gadget WITHOUT affecting the original main program and callback.
ex:
procedure mygadget()
;create custom gadget here
setwindowcallback @ threadcallback()
repeat
;;separate event loop
until whenever
endprocedure
what i want to do is be able to create a custom gadget i am working on (secret for now), and be able to have its own event loop and callback outside of the main program. i want to make a PB user library out of this gadget, and have the programmer be able to create the gadget with its own callback and NOT affect his main window callback.
openwindow(#window1,,,,)
setwindowcallback(@maincallback)
if createthread(thread,mygadget())
endif
threads and callback
-
localmotion34
- Enthusiast

- Posts: 665
- Joined: Fri Sep 12, 2003 10:40 pm
- Location: Tallahassee, Florida
threads and callback
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Sorry, but the way you want to do it is wrong 8O
SetWindowCallback can only be used ONCE
What you need to do is called SubClassing.
After creating the gadget you have to subclass it with:
old_proc = SetWindowLong_(MyControlhWnd, #GWL_WNDPROC, @MyControlWndProc())
And than you create a callback procedure:
MyControlWndProc(hWnd,Message,wParam,lParam)
and fill it with your code.
Don't forget to set the proper ProcedureReturn:
I don't have more time right now to show you the details, but search this forum under subclassing... 
SetWindowCallback can only be used ONCE
What you need to do is called SubClassing.
After creating the gadget you have to subclass it with:
old_proc = SetWindowLong_(MyControlhWnd, #GWL_WNDPROC, @MyControlWndProc())
And than you create a callback procedure:
MyControlWndProc(hWnd,Message,wParam,lParam)
and fill it with your code.
Don't forget to set the proper ProcedureReturn:
Code: Select all
Select Message
Case #WM_COMMAND
; your code
Default
ProcedureReturn CallWindowProc_(old_proc, hWnd, Message, wParam, lParam)
EndProcedure
