-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathCMenu.ahk
53 lines (41 loc) · 1.19 KB
/
CMenu.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Function: CMenu
Sets context menu for the control.
Dependencies:
<ShowMenu> 1.2, <Win> 1.2
Parameters:
HCtrl - Handle of the control.
MenuName - Name of the menu, optional.
Sub - Subroutine to be launched, optional.
Globals:
CMenu - Holds the menu definitions.
Remarks:
Parameters and variables of this function are equal to those
required by Showmenu. The menu for the control is launched as:
> ShowMenu(CMenu, %Hwnd%_menuName, %Hwnd%_sub)
About:
o Version 1.0 by majkinetor.
o Licensed under BSD <http://creativecommons.org/licenses/BSD/>.
*/
CMenu(HCtrl, MenuName="", Sub="") {
oldTrim := A_AutoTrim
AutoTrim, on
Sub = %Sub%
AutoTrim, %oldTrim%
Win_SubClass(HCtrl, "CMenu_wndProc")
return CMenu_wndProc(0, Sub, MenuName, HCtrl+0)
}
CMenu_wndProc(Hwnd, UMsg, WParam, LParam) {
static
global CMenu
static WM_RBUTTONUP = 0x205
if !Hwnd {
%LParam%_menuName := WParam, %LParam%_sub := Umsg
}
If (UMsg = WM_RBUTTONUP) {
return ShowMenu(CMenu, %Hwnd%_menuName, %Hwnd%_sub)
}
return DllCall("CallWindowProcA", "UInt", A_EventInfo, "UInt", hwnd, "UInt", uMsg, "UInt", wParam, "UInt", lParam)
}
#include *i ShowMenu.ahk
#include *i Win.ahk