Floating Popup Menus - Window Programming - Lecture Slides, Slides of Windows Programming

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

2011/2012

Uploaded on 11/06/2012

parasad
parasad 🇮🇳

4.5

(56)

131 documents

1 / 38

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
L e c t u r e #
L e c t u r e #
19
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26

Partial preview of the text

Download Floating Popup Menus - Window Programming - Lecture Slides and more Slides Windows Programming in PDF only on Docsity!

LL ee cc tt uu rr ee

Review of Last Lecture

GetSubMenu()

Retrieves a handle to the drop-down menu or submenu

activated by the specified menu item

Floating popup menus

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"

Floating popup menus

HMENU hPopupMenu;

Bar hPopupMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU_POPUP));

Bar hPopupMenu = GetSubMenu(hPopupMenu, 0);

Submenu numbering

0 1 2 3

WM_RBUTTONDOWN message

lParam: client-area coordinates of mouse cursor

low-word: x-coordinate high-word: y-coordinate

Floating popup menus: Main Window Procedure

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