1 HMENU hMenu = ::CreatePopupMenu();
2 HMENU hSubMenu = ::CreateMenu();
3 if (NULL != hSubMenu)
4 {
5 ::AppendMenu(hSubMenu, MF_STRING, 20, "Item 11");
6 ::AppendMenu(hSubMenu, MF_STRING , 21, "Item 12");
7 }
8 if (NULL != hMenu)
9 {
10 // add a few test items
11 ::AppendMenu(hMenu, MF_STRING, 1, "Item 1");
12 ::AppendMenu(hMenu, MF_POPUP , (UINT)hSubMenu, "Item 2");
13 ::AppendMenu(hMenu, MF_SEPARATOR, 2, NULL);
14 ::AppendMenu(hMenu, MF_STRING, 3, "Item 3");
15
16 ClientToScreen(&point);
17
18 int sel = ::TrackPopupMenuEx(hMenu,
19 TPM_CENTERALIGN | TPM_RETURNCMD,
20 point.x,
21 point.y,
22 m_hWnd,
23 NULL);
24 ::DestroyMenu(hMenu);
25 }