bonjour,
peut-on avoir plusieurs appels de setwindowcallback dans une fenetre ?
plusieurs setwindowcallback dans une fenetre ?
plusieurs setwindowcallback dans une fenetre ?
mmmmmmmmmmm.
-
- Messages : 1500
- Inscription : jeu. 25/mars/2004 11:23
- Localisation : Sophia Antipolis (Nice)
- Contact :
A partir d'un CallBack, tu peux en rappeler un autre
Mais un SetWinCB() ne permet d'en avoir qu'un seul en mémoire : le précédent sera effacé
Lionel

Mais un SetWinCB() ne permet d'en avoir qu'un seul en mémoire : le précédent sera effacé
Lionel
Webmestre de Basic-univers
Participez à son extension: ajouter vos programmes et partagez vos codes !
Participez à son extension: ajouter vos programmes et partagez vos codes !
en fait il peut y en avoir plusieurs, d'une certaine façon.
par défaut beaucoup d'objets windows ont déjà une callback d'activée.
mais quand on fait un SetWindowCallback() çà efface/remplace l'ancienne.
mais il est possible de procéder autrement en passant par l'api windows.
Il faut récupérer le pointeur de la fonction callback déjà existante et créée par windows.
Ensuite on attache notre propre fonction callback ( comme on le fait avec SetWindowCallback() ).
Enfin, lorsque notre callback à fait son travail, juste avant un ProcedureReturn, on appelle la fonction callback par défaut de windows.
On peut ainsi chainer plusieurs callbacks. C'est possible.
Sinon il y a aussi SetWindowsHookEx_()/CallNextHookEx_() mais c'est plus délicat et uniquement exécutable depuis une dll.
par défaut beaucoup d'objets windows ont déjà une callback d'activée.
mais quand on fait un SetWindowCallback() çà efface/remplace l'ancienne.
mais il est possible de procéder autrement en passant par l'api windows.
Il faut récupérer le pointeur de la fonction callback déjà existante et créée par windows.
Ensuite on attache notre propre fonction callback ( comme on le fait avec SetWindowCallback() ).
Enfin, lorsque notre callback à fait son travail, juste avant un ProcedureReturn, on appelle la fonction callback par défaut de windows.
On peut ainsi chainer plusieurs callbacks. C'est possible.
Code : Tout sélectionner
Macro SetWindowCallback2(hWnd, UserCallBack)
SetWindowLong_(hWnd, #GWL_WNDPROC, UserCallBack)
EndMacro
Global defTreeCB.l
Global defWindowCB1.l
Global defWindowCB2.l
Global defWindowCB3.l
Procedure.l myTreeCallBack(hWnd.l, uMsg.l, wParam.l, lParam.l)
Select uMsg
Case #WM_NOTIFY : Debug "tree: notify"
Case #WM_MOUSEMOVE : Debug "tree: mousemove"
Case #WM_LBUTTONUP : Debug "tree: lbuttonup"
EndSelect
ProcedureReturn CallWindowProc_(defTreeCB, hWnd, uMsg, wParam, lParam)
EndProcedure
Procedure.l myWindowCallBack1(hWnd.l, uMsg.l, wParam.l, lParam.l)
Select uMsg
Case #WM_CLOSE : Debug "window1: close"
Case #WM_COMMAND : Debug "window1: command"
Case #WM_MOUSEMOVE : Debug "window1: mousemove"
EndSelect
ProcedureReturn CallWindowProc_(defWindowCB1, hWnd, uMsg, wParam, lParam)
EndProcedure
Procedure.l myWindowCallBack2(hWnd.l, uMsg.l, wParam.l, lParam.l)
Select uMsg
Case #WM_CLOSE : Debug "window2: close"
Case #WM_COMMAND : Debug "window2: command"
Case #WM_MOUSEMOVE : Debug "window2: mousemove"
EndSelect
ProcedureReturn CallWindowProc_(defWindowCB2, hWnd, uMsg, wParam, lParam)
EndProcedure
Procedure.l myWindowCallBack3(hWnd.l, uMsg.l, wParam.l, lParam.l)
Select uMsg
Case #WM_CLOSE : Debug "window3: close"
Case #WM_COMMAND : Debug "window3: command"
Case #WM_MOUSEMOVE : Debug "window3: mousemove"
EndSelect
ProcedureReturn CallWindowProc_(defWindowCB3, hWnd, uMsg, wParam, lParam)
EndProcedure
If OpenWindow(0, 0, 0, 320, 240, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If CreateGadgetList(WindowID(0))
TreeGadget(0, 5, 5, 310, 100)
AddGadgetItem(0, 0, "test")
defTreeCB = SetWindowCallback2(GadgetID(0), @myTreeCallBack())
defWindowCB1 = SetWindowCallback2(WindowID(0), @myWindowCallBack1())
defWindowCB2 = SetWindowCallback2(WindowID(0), @myWindowCallBack2())
defWindowCB3 = SetWindowCallback2(WindowID(0), @myWindowCallBack3())
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
End
- Kwai chang caine
- Messages : 6989
- Inscription : sam. 23/sept./2006 18:32
- Localisation : Isere