Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Closing a toolbar after clicking anywhere, even inside it
#1
I have a toolbar. I make it appear by using a hotkey.
How can I make this toolbar disappear after clicking anywhere, including the toolbar itself?

Solution 1: I can add a command to close it, preceding every other command in this toolbar, but I have hundreds of commands in this toolbar, so it would be a long work to add this command to all other commands, one by one.

Second solution: I can create a function that closes this toolbar after detecting any left click, but this function does not work when I click inside the toolbar.

Any other solutions?
#2
Function ToolbarHook_ClickClose
Code:
Copy      Help
;/
function# hwnd message wParam lParam

sel message
,case WM_INITDIALOG
,int hh=SetWindowsHookEx(WH_MOUSE_LL &sub.Hook_WH_MOUSE_LL _hinst 0)
,SetProp(hwnd "MHCC" hh)
,case WM_DESTROY
,UnhookWindowsHookEx GetProp(hwnd "MHCC")
,case WM_TIMER
,sel wParam
,,case 1
,,KillTimer hwnd 1
,,clo hwnd


#sub Hook_WH_MOUSE_LL
function# nCode message MSLLHOOKSTRUCT&m
if(nCode<0) goto gNext

;if(message!=WM_MOUSEMOVE) OutWinMsg message 0 0 _s; out "%s at %i %i" _s m.pt.x m.pt.y

if message=WM_LBUTTONUP
,ARRAY(int) a; int i
,win("" "QM_toolbar" "" 0 "GetProp=MHCC" a)
,for(i 0 a.len) SetTimer a[i] 1 10 0

;gNext
ret CallNextHookEx(0 nCode message &m)

Toolbar Toolbar74
Code:
Copy      Help
;/hook ToolbarHook_ClickClose
1 :out 1
2 :out 2
#3
Magic!


Forum Jump:


Users browsing this thread: 1 Guest(s)