main(){
HWND main_wnd
=
CreateWindowA(wnd_class.lpszClassName, "", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0
,
0
,
640
,
480
, NULL, NULL, wnd_class.hInstance, NULL);
}
/
/
Creates an empty popup menu
HMENU MenuOne
=
CreatePopupMenu();
MENUITEMINFOA MenuOneInfo
=
{
0
};
/
/
Default size
MenuOneInfo.cbSize
=
sizeof(MENUITEMINFOA);
/
/
Selects what properties to retrieve
or
set
when GetMenuItemInfo
/
SetMenuItemInfo are called,
in
this case only dwTypeData which the contents of the menu item.
MenuOneInfo.fMask
=
MIIM_STRING;
BOOL
insertMenuItem
=
InsertMenuItemA(MenuOne,
0
, TRUE, &MenuOneInfo);
HMENU MenuTwo
=
CreatePopupMenu();
MENUITEMINFOA MenuTwoInfo
=
{
0
};
MenuTwoInfo.cbSize
=
sizeof(MENUITEMINFOA);
/
/
On this window hSubMenu should be included
in
Get
/
SetMenuItemInfo
MenuTwoInfo.fMask
=
(MIIM_STRING | MIIM_SUBMENU);
/
/
The menu
is
a sub menu of the first menu
MenuTwoInfo.hSubMenu
=
MenuOne;
/
/
The contents of the menu item
-
in
this case nothing
MenuTwoInfo.dwTypeData
=
"";
/
/
The length of the menu item text
-
in
the case
1
for
just a single NULL byte
MenuTwoInfo.cch
=
1
;
insertMenuItem
=
InsertMenuItemA(MenuTwo,
0
, TRUE, &MenuTwoInfo);
HHOOK setWindowsHook
=
SetWindowsHookExA(WH_CALLWNDPROC, HookCallback, NULL, GetCurrentThreadId());
TrackPopupMenu(
MenuTwo,
/
/
Handle to the menu we want to display,
for
us its the submenu we just created.
0
,
/
/
Options on how the menu
is
aligned, what clicks are allowed etc, we don't care.
0
,
/
/
Horizontal position
-
left hand side
0
,
/
/
Vertical position
-
Top edge
0
,
/
/
Reserved field, has to be
0
main_wnd,
/
/
Handle to the Window which owns the menu
NULL
/
/
This value
is
always ignored...
);
/
/
tidy up the screen