1 // Win32++ Version 7.3
\r
2 // Released: 30th November 2011
\r
6 // url: https://sourceforge.net/projects/win32-framework
\r
9 // Copyright (c) 2005-2011 David Nash
\r
11 // Permission is hereby granted, free of charge, to
\r
12 // any person obtaining a copy of this software and
\r
13 // associated documentation files (the "Software"),
\r
14 // to deal in the Software without restriction, including
\r
15 // without limitation the rights to use, copy, modify,
\r
16 // merge, publish, distribute, sublicense, and/or sell
\r
17 // copies of the Software, and to permit persons to whom
\r
18 // the Software is furnished to do so, subject to the
\r
19 // following conditions:
\r
21 // The above copyright notice and this permission notice
\r
22 // shall be included in all copies or substantial portions
\r
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
\r
26 // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
\r
27 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
\r
28 // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
\r
29 // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
\r
30 // ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
31 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
32 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
\r
33 // OR OTHER DEALINGS IN THE SOFTWARE.
\r
35 ////////////////////////////////////////////////////////
\r
38 ////////////////////////////////////////////////////////
\r
40 // Declaration of the CMenu class
\r
43 // 1) Owner-drawn menus send the WM_MEASUREITEM and WM_DRAWITEM messages
\r
44 // to the window that owns the menu. To manage owner drawing for menus,
\r
45 // handle these two messages in the CWnd's WndProc function.
\r
47 // 2) The CMenu pointer returned by FromHandle might be a temporary pointer. It
\r
48 // should be used immediately, not saved for later use.
\r
50 // 3) The CMenu pointers returned by FromHandle or GetSubMenu do not need
\r
51 // to be deleted. They are automatically deleted by the Win32++.
\r
53 // 4) CMenu pointers returned by GetSubMenu are deleted when the parent CMenu is
\r
54 // detached, destroyed or deconstructed.
\r
56 // 5) The HMENU that is attached to a CMenu object (using the attach function) is
\r
57 // automatically deleted when the CMenu object goes out of scope. Detach the
\r
58 // HMENU to stop it being deleted when CMenu's destructor is called.
\r
60 // 6) Pass CMenu objects by reference or by pointer when passing them as function
\r
63 // 7) In those functions that use a MENUITEMINFO structure, its cbSize member is
\r
64 // automatically set to the correct value.
\r
68 // void CView::CreatePopup()
\r
70 // CPoint pt = GetCursorPos();
\r
72 // // Create the menu
\r
74 // Popup.CreatePopupMenu();
\r
76 // // Add some menu items
\r
77 // Popup.AppendMenu(MF_STRING, 101, _T("Menu Item &1"));
\r
78 // Popup.AppendMenu(MF_STRING, 102, _T("Menu Item &2"));
\r
79 // Popup.AppendMenu(MF_STRING, 103, _T("Menu Item &3"));
\r
80 // Popup.AppendMenu(MF_SEPARATOR);
\r
81 // Popup.AppendMenu(MF_STRING, 104, _T("Menu Item &4"));
\r
83 // // Set menu item states
\r
84 // Popup.CheckMenuRadioItem(101, 101, 101, MF_BYCOMMAND);
\r
85 // Popup.CheckMenuItem(102, MF_BYCOMMAND | MF_CHECKED);
\r
86 // Popup.EnableMenuItem(103, MF_BYCOMMAND | MF_GRAYED);
\r
87 // Popup.SetDefaultItem(104);
\r
89 // // Display the popup menu
\r
90 // Popup.TrackPopupMenu(0, pt.x, pt.y, this);
\r
95 #if !defined(_WIN32XX_MENU_H_) && !defined(_WIN32_WCE)
\r
96 #define _WIN32XX_MENU_H_
\r
99 #include "wincore.h"
\r
106 // Forward declarations
\r
111 friend class CWinApp;
\r
115 CMenu() : m_hMenu(0), m_IsTmpMenu(FALSE) {}
\r
116 CMenu(UINT nID) : m_IsTmpMenu(FALSE)
\r
118 m_hMenu = ::LoadMenu(GetApp()->GetResourceHandle(), MAKEINTRESOURCE(nID));
\r
123 void Attach(HMENU hMenu);
\r
125 void CreatePopupMenu();
\r
126 void DestroyMenu();
\r
128 HMENU GetHandle() const;
\r
129 BOOL LoadMenu(LPCTSTR lpszResourceName);
\r
130 BOOL LoadMenu(UINT uIDResource);
\r
131 BOOL LoadMenuIndirect(const void* lpMenuTemplate);
\r
134 BOOL TrackPopupMenu(UINT uFlags, int x, int y, CWnd* pWnd, LPCRECT lpRect = 0);
\r
135 BOOL TrackPopupMenuEx(UINT uFlags, int x, int y, CWnd* pWnd, LPTPMPARAMS lptpm);
\r
137 //Menu Item Operations
\r
138 BOOL AppendMenu(UINT uFlags, UINT_PTR uIDNewItem = 0, LPCTSTR lpszNewItem = NULL);
\r
139 BOOL AppendMenu(UINT uFlags, UINT_PTR uIDNewItem, const CBitmap* pBmp);
\r
140 UINT CheckMenuItem(UINT uIDCheckItem, UINT uCheck);
\r
141 BOOL CheckMenuRadioItem(UINT uIDFirst, UINT uIDLast, UINT uIDItem, UINT uFlags);
\r
142 BOOL DeleteMenu(UINT uPosition, UINT uFlags);
\r
143 UINT EnableMenuItem(UINT uIDEnableItem, UINT uEnable);
\r
144 UINT GetDefaultItem(UINT gmdiFlags, BOOL fByPos = FALSE);
\r
145 DWORD GetMenuContextHelpId() const;
\r
147 #if(WINVER >= 0x0500) // Minimum OS required is Win2000
\r
148 BOOL GetMenuInfo(LPMENUINFO lpcmi) const;
\r
149 BOOL SetMenuInfo(LPCMENUINFO lpcmi);
\r
152 UINT GetMenuItemCount() const;
\r
153 UINT GetMenuItemID(int nPos) const;
\r
154 BOOL GetMenuItemInfo(UINT uItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos = FALSE);
\r
155 UINT GetMenuState(UINT uID, UINT uFlags) const;
\r
156 int GetMenuString(UINT uIDItem, LPTSTR lpString, int nMaxCount, UINT uFlags) const;
\r
157 int GetMenuString(UINT uIDItem, CString& rString, UINT uFlags) const;
\r
158 CMenu* GetSubMenu(int nPos);
\r
159 BOOL InsertMenu(UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem = 0, LPCTSTR lpszNewItem = NULL);
\r
160 BOOL InsertMenu(UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, const CBitmap* pBmp);
\r
161 BOOL InsertMenuItem(UINT uItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos = FALSE);
\r
162 BOOL ModifyMenu(UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem = 0, LPCTSTR lpszNewItem = NULL);
\r
163 BOOL ModifyMenu(UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, const CBitmap* pBmp);
\r
164 BOOL RemoveMenu(UINT uPosition, UINT uFlags);
\r
165 BOOL SetDefaultItem(UINT uItem, BOOL fByPos = FALSE);
\r
166 BOOL SetMenuContextHelpId(DWORD dwContextHelpId);
\r
167 BOOL SetMenuItemBitmaps(UINT uPosition, UINT uFlags, const CBitmap* pBmpUnchecked, const CBitmap* pBmpChecked);
\r
168 BOOL SetMenuItemInfo(UINT uItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos = FALSE);
\r
171 BOOL operator != (const CMenu& menu) const;
\r
172 BOOL operator == (const CMenu& menu) const;
\r
173 operator HMENU () const;
\r
176 CMenu(const CMenu&); // Disable copy construction
\r
177 CMenu& operator = (const CMenu&); // Disable assignment operator
\r
179 BOOL RemoveFromMap();
\r
180 std::vector<MenuPtr> m_vSubMenus; // A vector of smart pointers to CMenu
\r
185 inline CMenu::~CMenu()
\r
191 ::DestroyMenu(m_hMenu);
\r
197 m_vSubMenus.clear();
\r
200 inline void CMenu::AddToMap()
\r
201 // Store the HMENU and CMenu pointer in the HMENU map
\r
203 assert( GetApp() );
\r
206 GetApp()->m_csMapLock.Lock();
\r
207 GetApp()->m_mapHMENU.insert(std::make_pair(m_hMenu, this));
\r
208 GetApp()->m_csMapLock.Release();
\r
211 inline BOOL CMenu::RemoveFromMap()
\r
213 BOOL Success = FALSE;
\r
217 // Allocate an iterator for our HDC map
\r
218 std::map<HMENU, CMenu*, CompareHMENU>::iterator m;
\r
220 CWinApp* pApp = GetApp();
\r
223 // Erase the CDC pointer entry from the map
\r
224 pApp->m_csMapLock.Lock();
\r
225 for (m = pApp->m_mapHMENU.begin(); m != pApp->m_mapHMENU.end(); ++m)
\r
227 if (this == m->second)
\r
229 pApp->m_mapHMENU.erase(m);
\r
235 pApp->m_csMapLock.Release();
\r
243 inline BOOL CMenu::AppendMenu(UINT uFlags, UINT_PTR uIDNewItem /*= 0*/, LPCTSTR lpszNewItem /*= NULL*/)
\r
244 // Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu.
\r
246 assert(IsMenu(m_hMenu));
\r
247 return ::AppendMenu(m_hMenu, uFlags, uIDNewItem, lpszNewItem);
\r
250 inline BOOL CMenu::AppendMenu(UINT uFlags, UINT_PTR uIDNewItem, const CBitmap* pBmp)
\r
251 // Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu.
\r
253 assert(IsMenu(m_hMenu));
\r
255 return ::AppendMenu(m_hMenu, uFlags, uIDNewItem, (LPCTSTR)pBmp->GetHandle());
\r
258 inline void CMenu::Attach(HMENU hMenu)
\r
259 // Attaches an existing menu to this CMenu
\r
261 if (m_hMenu != NULL && m_hMenu != hMenu)
\r
263 ::DestroyMenu(Detach());
\r
273 inline UINT CMenu::CheckMenuItem(UINT uIDCheckItem, UINT uCheck)
\r
274 // Sets the state of the specified menu item's check-mark attribute to either selected or clear.
\r
276 assert(IsMenu(m_hMenu));
\r
277 return ::CheckMenuItem(m_hMenu, uIDCheckItem, uCheck);
\r
280 inline BOOL CMenu::CheckMenuRadioItem(UINT uIDFirst, UINT uIDLast, UINT uIDItem, UINT uFlags)
\r
281 // Checks a specified menu item and makes it a radio item. At the same time, the function clears
\r
282 // all other menu items in the associated group and clears the radio-item type flag for those items.
\r
284 assert(IsMenu(m_hMenu));
\r
285 return ::CheckMenuRadioItem(m_hMenu, uIDFirst, uIDLast, uIDItem, uFlags);
\r
288 inline void CMenu::CreateMenu()
\r
289 // Creates an empty menu.
\r
291 assert(NULL == m_hMenu);
\r
292 m_hMenu = ::CreateMenu();
\r
296 inline void CMenu::CreatePopupMenu()
\r
297 // Creates a drop-down menu, submenu, or shortcut menu. The menu is initially empty.
\r
299 assert(NULL == m_hMenu);
\r
300 m_hMenu = ::CreatePopupMenu();
\r
304 inline BOOL CMenu::DeleteMenu(UINT uPosition, UINT uFlags)
\r
305 // Deletes an item from the specified menu.
\r
307 assert(IsMenu(m_hMenu));
\r
308 return ::DeleteMenu(m_hMenu, uPosition, uFlags);
\r
311 inline void CMenu::DestroyMenu()
\r
312 // Destroys the menu and frees any memory that the menu occupies.
\r
314 if (::IsMenu(m_hMenu))
\r
315 ::DestroyMenu(m_hMenu);
\r
319 m_vSubMenus.clear();
\r
322 inline HMENU CMenu::Detach()
\r
323 // Detaches the HMENU from this CMenu. If the HMENU is not detached it will be
\r
324 // destroyed when this CMenu is deconstructed.
\r
326 assert(IsMenu(m_hMenu));
\r
327 HMENU hMenu = m_hMenu;
\r
330 m_vSubMenus.clear();
\r
334 inline HMENU CMenu::GetHandle() const
\r
335 // Returns the HMENU assigned to this CMenu
\r
340 inline UINT CMenu::EnableMenuItem(UINT uIDEnableItem, UINT uEnable)
\r
341 // Enables, disables, or grays the specified menu item.
\r
342 // The uEnable parameter must be a combination of either MF_BYCOMMAND or MF_BYPOSITION
\r
343 // and MF_ENABLED, MF_DISABLED, or MF_GRAYED.
\r
345 assert(IsMenu(m_hMenu));
\r
346 return ::EnableMenuItem(m_hMenu, uIDEnableItem, uEnable);
\r
349 inline UINT CMenu::GetDefaultItem(UINT gmdiFlags, BOOL fByPos /*= FALSE*/)
\r
350 // Determines the default menu item.
\r
351 // The gmdiFlags parameter specifies how the function searches for menu items.
\r
352 // This parameter can be zero or more of the following values: GMDI_GOINTOPOPUPS; GMDI_USEDISABLED.
\r
354 assert(IsMenu(m_hMenu));
\r
355 return ::GetMenuDefaultItem(m_hMenu, fByPos, gmdiFlags);
\r
358 inline DWORD CMenu::GetMenuContextHelpId() const
\r
359 // Retrieves the Help context identifier associated with the menu.
\r
361 assert(IsMenu(m_hMenu));
\r
362 return ::GetMenuContextHelpId(m_hMenu);
\r
365 #if(WINVER >= 0x0500)
\r
366 // minimum OS required : Win2000
\r
368 inline BOOL CMenu::GetMenuInfo(LPMENUINFO lpcmi) const
\r
369 // Retrieves the menu information.
\r
371 assert(IsMenu(m_hMenu));
\r
372 return ::GetMenuInfo(m_hMenu, lpcmi);
\r
375 inline BOOL CMenu::SetMenuInfo(LPCMENUINFO lpcmi)
\r
376 // Sets the menu information from the specified MENUINFO structure.
\r
378 assert(IsMenu(m_hMenu));
\r
379 return ::SetMenuInfo(m_hMenu, lpcmi);
\r
384 inline UINT CMenu::GetMenuItemCount() const
\r
385 // Retrieves the number of menu items.
\r
387 assert(IsMenu(m_hMenu));
\r
388 return ::GetMenuItemCount(m_hMenu);
\r
391 inline UINT CMenu::GetMenuItemID(int nPos) const
\r
392 // Retrieves the menu item identifier of a menu item located at the specified position
\r
394 assert(IsMenu(m_hMenu));
\r
395 return ::GetMenuItemID(m_hMenu, nPos);
\r
398 inline BOOL CMenu::GetMenuItemInfo(UINT uItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos /*= FALSE*/)
\r
399 // retrieves information about the specified menu item.
\r
401 assert(IsMenu(m_hMenu));
\r
402 assert(lpMenuItemInfo);
\r
403 lpMenuItemInfo->cbSize = GetSizeofMenuItemInfo();
\r
404 return ::GetMenuItemInfo(m_hMenu, uItem, fByPos, lpMenuItemInfo);
\r
407 inline UINT CMenu::GetMenuState(UINT uID, UINT uFlags) const
\r
408 // Retrieves the menu flags associated with the specified menu item.
\r
409 // Possible values for uFlags are: MF_BYCOMMAND (default) or MF_BYPOSITION.
\r
411 assert(IsMenu(m_hMenu));
\r
412 return ::GetMenuState(m_hMenu, uID, uFlags);
\r
415 inline int CMenu::GetMenuString(UINT uIDItem, LPTSTR lpString, int nMaxCount, UINT uFlags) const
\r
416 // Copies the text string of the specified menu item into the specified buffer.
\r
418 assert(IsMenu(m_hMenu));
\r
420 return ::GetMenuString(m_hMenu, uIDItem, lpString, nMaxCount, uFlags);
\r
423 inline int CMenu::GetMenuString(UINT uIDItem, CString& rString, UINT uFlags) const
\r
424 // Copies the text string of the specified menu item into the specified buffer.
\r
426 assert(IsMenu(m_hMenu));
\r
427 return ::GetMenuString(m_hMenu, uIDItem, (LPTSTR)rString.c_str(), rString.GetLength(), uFlags);
\r
430 inline CMenu* CMenu::GetSubMenu(int nPos)
\r
431 // Retrieves the CMenu object of a pop-up menu.
\r
433 assert(IsMenu(m_hMenu));
\r
434 CMenu* pMenu = new CMenu;
\r
435 pMenu->m_hMenu = ::GetSubMenu(m_hMenu, nPos);
\r
436 pMenu->m_IsTmpMenu = TRUE;
\r
437 m_vSubMenus.push_back(pMenu);
\r
441 inline BOOL CMenu::InsertMenu(UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem /*= 0*/, LPCTSTR lpszNewItem /*= NULL*/)
\r
442 // Inserts a new menu item into a menu, moving other items down the menu.
\r
444 assert(IsMenu(m_hMenu));
\r
445 return ::InsertMenu(m_hMenu, uPosition, uFlags, uIDNewItem, lpszNewItem);
\r
448 inline BOOL CMenu::InsertMenu(UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, const CBitmap* pBmp)
\r
449 // Inserts a new menu item into a menu, moving other items down the menu.
\r
451 assert(IsMenu(m_hMenu));
\r
452 return ::InsertMenu(m_hMenu, uPosition, uFlags, uIDNewItem, (LPCTSTR)pBmp->GetHandle());
\r
455 inline BOOL CMenu::InsertMenuItem(UINT uItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos /*= FALSE*/)
\r
456 // Inserts a new menu item at the specified position in a menu.
\r
458 assert(IsMenu(m_hMenu));
\r
459 assert(lpMenuItemInfo);
\r
460 lpMenuItemInfo->cbSize = GetSizeofMenuItemInfo();
\r
461 return ::InsertMenuItem(m_hMenu, uItem, fByPos, lpMenuItemInfo);
\r
464 inline BOOL CMenu::LoadMenu(LPCTSTR lpszResourceName)
\r
465 // Loads the menu from the specified windows resource.
\r
467 assert(NULL == m_hMenu);
\r
468 assert(lpszResourceName);
\r
469 m_hMenu = ::LoadMenu(GetApp()->GetResourceHandle(), lpszResourceName);
\r
470 if (m_hMenu) AddToMap();
\r
471 return NULL != m_hMenu;
\r
474 inline BOOL CMenu::LoadMenu(UINT uIDResource)
\r
475 // Loads the menu from the specified windows resource.
\r
477 assert(NULL == m_hMenu);
\r
478 m_hMenu = ::LoadMenu(GetApp()->GetResourceHandle(), MAKEINTRESOURCE(uIDResource));
\r
479 if (m_hMenu) AddToMap();
\r
480 return NULL != m_hMenu;
\r
483 inline BOOL CMenu::LoadMenuIndirect(const void* lpMenuTemplate)
\r
484 // Loads the specified menu template and assigns it to this CMenu.
\r
486 assert(NULL == m_hMenu);
\r
487 assert(lpMenuTemplate);
\r
488 m_hMenu = ::LoadMenuIndirect(lpMenuTemplate);
\r
489 if (m_hMenu) AddToMap();
\r
490 return NULL != m_hMenu;
\r
493 inline BOOL CMenu::ModifyMenu(UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem /*= 0*/, LPCTSTR lpszNewItem /*= NULL*/)
\r
494 // Changes an existing menu item. This function is used to specify the content, appearance, and behavior of the menu item.
\r
496 assert(IsMenu(m_hMenu));
\r
497 return ::ModifyMenu(m_hMenu, uPosition, uFlags, uIDNewItem, lpszNewItem);
\r
500 inline BOOL CMenu::ModifyMenu(UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, const CBitmap* pBmp)
\r
501 // Changes an existing menu item. This function is used to specify the content, appearance, and behavior of the menu item.
\r
503 assert(IsMenu(m_hMenu));
\r
505 return ::ModifyMenu(m_hMenu, uPosition, uFlags, uIDNewItem, (LPCTSTR)pBmp->GetHandle());
\r
508 inline BOOL CMenu::RemoveMenu(UINT uPosition, UINT uFlags)
\r
509 // Deletes a menu item or detaches a submenu from the menu.
\r
511 assert(IsMenu(m_hMenu));
\r
512 return ::RemoveMenu(m_hMenu, uPosition, uFlags);
\r
515 inline BOOL CMenu::SetDefaultItem(UINT uItem, BOOL fByPos /*= FALSE*/)
\r
516 // sets the default menu item for the menu.
\r
518 assert(IsMenu(m_hMenu));
\r
519 return ::SetMenuDefaultItem(m_hMenu, uItem, fByPos);
\r
522 inline BOOL CMenu::SetMenuContextHelpId(DWORD dwContextHelpId)
\r
523 // Associates a Help context identifier with the menu.
\r
525 assert(IsMenu(m_hMenu));
\r
526 return ::SetMenuContextHelpId(m_hMenu, dwContextHelpId);
\r
529 inline BOOL CMenu::SetMenuItemBitmaps(UINT uPosition, UINT uFlags, const CBitmap* pBmpUnchecked, const CBitmap* pBmpChecked)
\r
530 // Associates the specified bitmap with a menu item.
\r
532 assert(IsMenu(m_hMenu));
\r
533 return ::SetMenuItemBitmaps(m_hMenu, uPosition, uFlags, *pBmpUnchecked, *pBmpChecked);
\r
536 inline BOOL CMenu::SetMenuItemInfo(UINT uItem, LPMENUITEMINFO lpMenuItemInfo, BOOL fByPos /*= FALSE*/)
\r
537 // Changes information about a menu item.
\r
539 assert(IsMenu(m_hMenu));
\r
540 assert(lpMenuItemInfo);
\r
541 lpMenuItemInfo->cbSize = GetSizeofMenuItemInfo();
\r
542 return ::SetMenuItemInfo(m_hMenu, uItem, fByPos, lpMenuItemInfo);
\r
545 inline BOOL CMenu::TrackPopupMenu(UINT uFlags, int x, int y, CWnd* pWnd, LPCRECT lpRect /*= 0*/)
\r
546 // Displays a shortcut menu at the specified location and tracks the selection of items on the menu.
\r
548 assert(IsMenu(m_hMenu));
\r
549 HWND hWnd = pWnd? pWnd->GetHwnd() : 0;
\r
550 return ::TrackPopupMenu(m_hMenu, uFlags, x, y, 0, hWnd, lpRect);
\r
553 inline BOOL CMenu::TrackPopupMenuEx(UINT uFlags, int x, int y, CWnd* pWnd, LPTPMPARAMS lptpm)
\r
554 // Displays a shortcut menu at the specified location and tracks the selection of items on the shortcut menu.
\r
556 assert(IsMenu(m_hMenu));
\r
557 HWND hWnd = pWnd? pWnd->GetHwnd() : 0;
\r
558 return ::TrackPopupMenuEx(m_hMenu, uFlags, x, y, hWnd, lptpm);
\r
561 inline BOOL CMenu::operator != (const CMenu& menu) const
\r
562 // Returns TRUE if the two menu objects are not equal.
\r
564 return menu.m_hMenu != m_hMenu;
\r
567 inline BOOL CMenu::operator == (const CMenu& menu) const
\r
568 // Returns TRUE of the two menu object are equal
\r
570 return menu.m_hMenu == m_hMenu;
\r
573 inline CMenu::operator HMENU () const
\r
574 // Retrieves the menu's handle.
\r
580 ///////////////////////////////////////
\r
581 // Global functions
\r
584 inline CMenu* FromHandle(HMENU hMenu)
\r
585 // Returns the CMenu object associated with the menu handle (HMENU).
\r
587 assert( GetApp() );
\r
588 CMenu* pMenu = GetApp()->GetCMenuFromMap(hMenu);
\r
589 if (::IsMenu(hMenu) && pMenu == 0)
\r
591 GetApp()->AddTmpMenu(hMenu);
\r
592 pMenu = GetApp()->GetCMenuFromMap(hMenu);
\r
597 } // namespace Win32xx
\r
599 #endif // _WIN32XX_MENU_H_
\r