Right, I want to change an existing blitz built gadget to a toggle type. But now im unsure of what to do inorder to overcome some short commings in my code;
The User32.decls file in userlib folder...
Blitz code...
So far, this sort of works as expected. Now I need to figure out how to deal with 2 problems ...
#1) After pushing one of these gadgets down, tapping tab with pop the gadget back up
#2) Clicking a gadget thats already down, then while holding the mouse, drag the mouse away and release will pop the gadget back up :(
I guess what I need to do is write some sort of .dll to hook into the gadget to deal with these events when they happen. As I dont really know a whole lot about windows hooks, anyone got some pointers on how to implement it?. I plan on using purebasic to code any such .dll thats gona be needed.
Or anyone got a better method to pull off what i want to do (not using a canvas if possible).
The User32.decls file in userlib folder...
.lib "user32.dll" SendMessage%(hWnd%,Msg%,wParam%,lParam%):"SendMessageA"
Blitz code...
;Event flags Const EVENT_KEYDOWN = $101 ; Key pressed Const EVENT_KEYUP = $102 ; Key released Const EVENT_KEYCHAR = $103 ; Key generated ASCII character Const EVENT_MOUSE_DOWN = $201 ; Mouse button pressed Const EVENT_MOUSE_UP = $202 ; Mouse button released Const EVENT_MOUSE_MOVE = $203 ; Mouse moved Const EVENT_MOUSE_ENTER = $205 ; Mouse enters canvas area Const EVENT_MOUSE_EXIT = $206 ; Mouse leaves canvas area Const EVENT_GADGET = $401 ; Gadget clicked Const EVENT_MOVE = $801 ; Window moved Const EVENT_SIZE = $802 ; Window resized Const EVENT_CLOSE = $803 ; Window closed Const EVENT_MENU = $1001 ; Menu item selected Const EVENT_APP_PAUSED = $2001 ; The app has been suspended (loss windows focus) Const EVENT_APP_STARTED = $2002 ; The app has been resumed (regained windows focus) Const EVENT_TIMERTICK = $4001 ; A blitz timer has ticked Const QUERYID_WIN32_HWND = 1 ; Win32 HWND ;Win32 Const BM_SETSTATE= 243 ;Set a buttons state (up / down) ;Example code... pWin=CreateWindow("Toggle gadget",100,100,400,300,0,%1011) pGadget1=CreateButton("Layer1",10,14,100,24,pWin,0) pGadget2=CreateButton("Layer2",10,54,100,24,pWin,0) pGadget3=CreateButton("Layer2",10,88,100,24,pWin,0) pHwnd1=QueryObject(pGadget1,QUERYID_WIN32_HWND) ;Gets a windows handle pHwnd2=QueryObject(pGadget2,QUERYID_WIN32_HWND) pHwnd3=QueryObject(pGadget3,QUERYID_WIN32_HWND) bDone=False Repeat Ev=WaitEvent() Es=EventSource() Select Es Case pGadget1 SetStatusText(pWin,"Gadget1 - $"+Hex$(Ev)+" "+ButtonState(pGadget1)+" $"+Hex(pHwnd1)) SendMessage(pHwnd1,BM_SETSTATE,1,0) SendMessage(pHwnd2,BM_SETSTATE,0,0) SendMessage(pHwnd3,BM_SETSTATE,0,0) Case pGadget2 SetStatusText(pWin,"Gadget2 - $"+Hex$(Ev)+" "+ButtonState(pGadget1)+" $"+Hex(pHwnd2)) SendMessage(pHwnd1,BM_SETSTATE,0,0) SendMessage(pHwnd2,BM_SETSTATE,1,0) SendMessage(pHwnd3,BM_SETSTATE,0,0) Case pGadget3 SetStatusText(pWin,"Gadget3 - $"+Hex$(Ev)+" "+ButtonState(pGadget1)+" $"+Hex(pHwnd3)) SendMessage(pHwnd1,BM_SETSTATE,0,0) SendMessage(pHwnd2,BM_SETSTATE,0,0) SendMessage(pHwnd3,BM_SETSTATE,1,0) Case pWin ;Window based events Select Ev Case EVENT_CLOSE bDone=True End Select End Select Until KeyDown(1) Or bDone=True End
So far, this sort of works as expected. Now I need to figure out how to deal with 2 problems ...
#1) After pushing one of these gadgets down, tapping tab with pop the gadget back up
#2) Clicking a gadget thats already down, then while holding the mouse, drag the mouse away and release will pop the gadget back up :(
I guess what I need to do is write some sort of .dll to hook into the gadget to deal with these events when they happen. As I dont really know a whole lot about windows hooks, anyone got some pointers on how to implement it?. I plan on using purebasic to code any such .dll thats gona be needed.
Or anyone got a better method to pull off what i want to do (not using a canvas if possible).