






























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Floating popup menus, Submenu numbering, Structures to represent a point, Main Window Procedure, Mouse Tracking, Manipulating Menus at runtime, Window menu are the terms you can learn in this lecture and few others as well.
Typology: Slides
1 / 38
This page cannot be seen from the preview
Don't miss anything!































Review of Last Lecture
Retrieves a handle to the drop-down menu or submenu
activated by the specified menu item
IDR_MENU_POPUP MENU DISCARDABLE BEGIN POPUP "Popup Menu" BEGIN MENUITEM "&Line", ID_POPUPMENU_LINE MENUITEM "&Circle", ID_POPUPMENU_CIRCLE MENUITEM "&Rectangle", ID_POPUPMENU_RECTANGLE POPUP "&Other" BEGIN MENUITEM "&Polygon", ID_OTHER_POLYGON MENUITEM "&Text Message", ID_OTHER_TEXTMESSAGE END END END
Only one drop-down starting with POPUP "Popup Menu"
HMENU hPopupMenu;
Bar hPopupMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU_POPUP));
Bar hPopupMenu = GetSubMenu(hPopupMenu, 0);
Submenu numbering
0 1 2 3
lParam: client-area coordinates of mouse cursor
low-word: x-coordinate high-word: y-coordinate
POINTS pts; POINT pt; … … … … case WM_RBUTTONDOWN: Bar pts = MAKEPOINTS(lParam); BarS pt.x = pts.x; BarE pt.y = pts.y; Bar ClientToScreen(hWnd, &pt); Bar result = TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD | TPM_LEFTBUTTON, pt.x, pt.y, 0, hWnd, 0);
Mouse Tracking
Floating popup menus: Main Window Procedure
result = TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD | TPM_LEFTBUTTON, pt.x, pt.y, 0, hWnd, 0);
switch(result) { case ID_POPUPMENU_CIRCLE: MessageBox(hWnd, "Circle", "Popup clicked", MB_OK); break;
case ID_POPUPMENU_RECTANGLE: MessageBox(hWnd, “Rectangle", "Popup clicked", MB_OK); break;
} Docsity.com
Manipulating Menus at runtime
HMENU CreateMenu(VOID);
creates an empty menu
BOOL AppendMenu(… … …);
appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu.
BOOL InsertMenu (… … …);
inserts a new menu item into a menu, moving other items down the menu.
Manipulating Menus at runtime
BOOL ModifyMenu(… … …);
changes an existing menu item
Superseded by
BOOL SetMenuItemInfo(… … …);
changes an existing menu item
modified system/window menu
Right-click at the taskbar buttons
Most applications
MSDN library