Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

719 lines
22 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1992 - 1999
  6. //
  7. // File: menubtns.cpp
  8. //
  9. // Contents: Menu Buttons implementation
  10. //
  11. // History: 08-27-99 AnandhaG Created
  12. //
  13. //--------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "AMC.h"
  16. #include "ChildFrm.h"
  17. #include "menubtns.h"
  18. #include "AMCView.h"
  19. #include "mainfrm.h"
  20. #include "menubar.h"
  21. #include "util.h" // GetTBBtnTextAndStatus()
  22. CMenuButtonsMgrImpl::CMenuButtonsMgrImpl()
  23. : m_pChildFrame(NULL), m_pMainFrame(NULL),
  24. m_pMenuBar(NULL)
  25. {
  26. m_MenuButtons.clear();
  27. m_AttachedMenuButtons.clear();
  28. }
  29. CMenuButtonsMgrImpl::~CMenuButtonsMgrImpl()
  30. {
  31. m_MenuButtons.clear();
  32. m_AttachedMenuButtons.clear();
  33. }
  34. //+-------------------------------------------------------------------
  35. //
  36. // Member: ScInit
  37. //
  38. // Synopsis: Init the Menubuttons mgr.
  39. //
  40. // Arguments: [pMainFrame] - Ptr to Main Frame window.
  41. // [pChildFrameWnd] - Ptr to child frame window.
  42. //
  43. // Returns: SC
  44. //
  45. //--------------------------------------------------------------------
  46. SC CMenuButtonsMgrImpl::ScInit (CMainFrame* pMainFrame, CChildFrame* pChildFrameWnd)
  47. {
  48. DECLARE_SC(sc, _T("CMenuButtonsMgrImpl::ScInit"));
  49. if ( (NULL == pChildFrameWnd) ||
  50. (NULL == pMainFrame))
  51. return (sc = E_INVALIDARG);
  52. m_pChildFrame = pChildFrameWnd;
  53. m_pMainFrame = pMainFrame;
  54. return sc;
  55. }
  56. //+-------------------------------------------------------------------
  57. //
  58. // Member: ScAddMenuButton
  59. //
  60. // Synopsis: Adds a menu button to the data structure
  61. // and calls ScAddMenuButtonToMenu.
  62. //
  63. // Arguments:
  64. // [pMenuBtnNotifyClbk] - Notify callback for button click.
  65. // [idCommand] - Button command id.
  66. // [lpButtonText] - Button text.
  67. // [lpStatusText] - Button status text.
  68. //
  69. // Returns: SC
  70. //
  71. // Note : The status text is not used.
  72. //
  73. //--------------------------------------------------------------------
  74. SC CMenuButtonsMgrImpl::ScAddMenuButton(
  75. CMenuButtonNotify* pMenuBtnNotifyClbk,
  76. INT idCommand,
  77. LPCOLESTR lpButtonText,
  78. LPCOLESTR lpStatusText)
  79. {
  80. DECLARE_SC(sc, _T("CMenuButtonsMgrImpl::ScAddMenuButton"));
  81. // Validate the data
  82. if ( (NULL == pMenuBtnNotifyClbk) ||
  83. (NULL == lpButtonText) ||
  84. (NULL == lpStatusText) )
  85. return (sc = E_INVALIDARG);
  86. // Add the data to our data structure
  87. MMC_MenuButtonCollection::iterator it;
  88. it = GetMMCMenuButton( pMenuBtnNotifyClbk, idCommand);
  89. if (it != m_MenuButtons.end())
  90. {
  91. // Duplicate Menu button found.
  92. // The pMenuButtonNofifyClbk represents IMenuButton
  93. // given to the snapin and we found another button
  94. // with idCommand already added by this snapin.
  95. // For compatibility reasons (disk mgmt) this is not an error.
  96. return (sc = S_OK);
  97. }
  98. MMC_MENUBUTTON mmb;
  99. mmb.pMenuButtonNotifyClbk = pMenuBtnNotifyClbk;
  100. mmb.idCommand = idCommand;
  101. USES_CONVERSION;
  102. mmb.lpButtonText = OLE2CT(lpButtonText);
  103. mmb.lpStatusText = OLE2CT(lpStatusText);
  104. // Add the MMC_MENUBUTTON to the our array.
  105. m_MenuButtons.push_back(mmb);
  106. // Add the menubuttons to main menu
  107. sc = ScAddMenuButtonsToMainMenu();
  108. if (sc)
  109. return sc;
  110. return (sc);
  111. }
  112. //+-------------------------------------------------------------------
  113. //
  114. // Member: ScModifyMenuButton
  115. //
  116. // Synopsis: Modify button text or status text for menu button
  117. //
  118. // Arguments:
  119. // [pMenuBtnNotifyClbk] - Notify callback for button click.
  120. // [idCommand] - Button command id.
  121. // [lpButtonText] - Button text.
  122. // [lpStatusText] - Button status text.
  123. //
  124. // Returns: SC
  125. //
  126. // Note : The status text is not used.
  127. //
  128. //--------------------------------------------------------------------
  129. SC CMenuButtonsMgrImpl::ScModifyMenuButton(
  130. CMenuButtonNotify* pMenuBtnNotifyClbk,
  131. INT idCommand,
  132. LPCOLESTR lpButtonText,
  133. LPCOLESTR lpStatusText)
  134. {
  135. DECLARE_SC(sc, _T("CMenuButtonsMgrImpl::ScModifyMenuButton"));
  136. // Validate the data
  137. if ( (NULL == pMenuBtnNotifyClbk) ||
  138. (NULL == lpButtonText) ||
  139. (NULL == lpStatusText) )
  140. return (sc = E_INVALIDARG);
  141. if ( (NULL == m_pChildFrame) ||
  142. (false == m_pChildFrame->IsChildFrameActive()) )
  143. return (sc = E_UNEXPECTED);
  144. // Iterate thro the vector and find the MMC_MENUBUTTON for
  145. // given CMenuButtonNotify* and Command id of button.
  146. MMC_MenuButtonCollection::iterator it;
  147. it = GetMMCMenuButton( pMenuBtnNotifyClbk, idCommand);
  148. if (it == m_MenuButtons.end())
  149. {
  150. // Menu button not found.
  151. // The pMenuButtonNofifyClbk represents IMenuButton
  152. // given to the snapin and we could not find a menu button
  153. // with idCommand already added by this snapin.
  154. return (sc = E_INVALIDARG);
  155. }
  156. it->pMenuButtonNotifyClbk = pMenuBtnNotifyClbk;
  157. it->idCommand = idCommand;
  158. USES_CONVERSION;
  159. it->lpButtonText = OLE2CT(lpButtonText);
  160. it->lpStatusText = OLE2CT(lpStatusText);
  161. if (NULL == m_pMenuBar)
  162. return (sc = E_UNEXPECTED);
  163. // Change the name of the menu item.
  164. if (-1 != it->nCommandIDFromMenuBar)
  165. {
  166. sc = (m_pMenuBar->SetMenuButton(it->nCommandIDFromMenuBar, it->lpButtonText.data()) == -1)
  167. ? E_FAIL : S_OK;
  168. if (sc)
  169. return sc;
  170. }
  171. return (sc);
  172. }
  173. //+-------------------------------------------------------------------
  174. //
  175. // Member: ScModifyMenuButtonState
  176. //
  177. // Synopsis: Modify menu button state.
  178. //
  179. // Arguments:
  180. // [pMenuBtnNotifyClbk] - Notify callback for button click.
  181. // [idCommand] - Button command id.
  182. // [nState] - The state to be modified.
  183. // [bState] - Set or Reset the state.
  184. //
  185. // Returns: SC
  186. //
  187. //--------------------------------------------------------------------
  188. SC CMenuButtonsMgrImpl::ScModifyMenuButtonState(
  189. CMenuButtonNotify* pMenuBtnNotifyClbk,
  190. INT idCommand,
  191. MMC_BUTTON_STATE nState,
  192. BOOL bState)
  193. {
  194. AFX_MANAGE_STATE (AfxGetAppModuleState());
  195. DECLARE_SC(sc, _T("CMenuButtonsMgrImpl::ScModifyMenuButtonState"));
  196. // Validate the data
  197. if (NULL == pMenuBtnNotifyClbk)
  198. return (sc = E_INVALIDARG);
  199. if (NULL == m_pChildFrame)
  200. return (sc = E_UNEXPECTED);
  201. // If childframe is not active, menus for this viewdoes not exist.
  202. if (false == m_pChildFrame->IsChildFrameActive())
  203. {
  204. switch (nState)
  205. {
  206. case ENABLED:
  207. // Enabling is illegal disabling is Ok (do nothing).
  208. sc = bState ? E_FAIL : S_OK;
  209. break;
  210. case HIDDEN:
  211. // Hiding is Ok(do nothing), Un-hiding is illegal.
  212. sc = bState ? S_OK : E_FAIL;
  213. break;
  214. case BUTTONPRESSED:
  215. sc = E_FAIL; // Always fail.
  216. break;
  217. default:
  218. ASSERT(FALSE);
  219. sc = E_FAIL;
  220. break;
  221. }
  222. return sc;
  223. }
  224. // Iterate thro the vector and find the MMC_MENUBUTTON for
  225. // given CMenuButtonNotify* and Command id of button.
  226. MMC_MenuButtonCollection::iterator it;
  227. it = GetMMCMenuButton( pMenuBtnNotifyClbk, idCommand);
  228. if (it == m_MenuButtons.end())
  229. {
  230. // Menu button not found.
  231. // The pMenuButtonNofifyClbk represents IMenuButton
  232. // given to the snapin and we could not find a menu button
  233. // with idCommand already added by this snapin.
  234. return (sc = E_INVALIDARG);
  235. }
  236. // Note the hidden state specified by the snapin.
  237. if (HIDDEN == nState)
  238. {
  239. bool bShow = (FALSE == bState);
  240. it->SetShowMenu(bShow);
  241. // If a menu button is to be un-hidden make sure that snapin buttons
  242. // are allowed in this view. Ask view-data for this information.
  243. if (bShow)
  244. {
  245. CAMCView* pAMCView = m_pChildFrame->GetAMCView();
  246. if (NULL == pAMCView)
  247. return (sc = E_UNEXPECTED);
  248. SViewData* pViewData = pAMCView->GetViewData();
  249. if (NULL == pViewData)
  250. return (sc = E_UNEXPECTED);
  251. // We have noted the hidden state of the button.
  252. // Return S_OK if menubuttons are disabled for this view.
  253. // Later when the menus are turned on the hidden state will
  254. // be properly restored.
  255. if (! pViewData->IsSnapinMenusAllowed())
  256. return (sc = S_OK);
  257. }
  258. }
  259. if (NULL == m_pMenuBar)
  260. return (sc = E_UNEXPECTED);
  261. BOOL bRet = FALSE;
  262. switch (nState)
  263. {
  264. case ENABLED:
  265. bRet = m_pMenuBar->EnableButton(it->nCommandIDFromMenuBar , bState);
  266. break;
  267. case HIDDEN:
  268. bRet = m_pMenuBar->HideButton(it->nCommandIDFromMenuBar , bState);
  269. break;
  270. case BUTTONPRESSED:
  271. bRet = m_pMenuBar->PressButton(it->nCommandIDFromMenuBar, bState);
  272. break;
  273. default:
  274. ASSERT(FALSE);
  275. bRet = FALSE;
  276. break;
  277. }
  278. sc = bRet ? S_OK : E_FAIL;
  279. return sc;
  280. }
  281. //+-------------------------------------------------------------------
  282. //
  283. // Member: ScAddMenuButtonsToMainMenu
  284. //
  285. // Synopsis: Add the menu buttons that are not yet added to
  286. // the main menu.
  287. //
  288. // Arguments: None
  289. //
  290. // Returns: SC
  291. //
  292. //--------------------------------------------------------------------
  293. SC CMenuButtonsMgrImpl::ScAddMenuButtonsToMainMenu ()
  294. {
  295. AFX_MANAGE_STATE (AfxGetAppModuleState());
  296. DECLARE_SC(sc, _T("CMenuButtonsMgrImpl::ScAddMenuButtonsToMainMenu"));
  297. // To add a menu button the following conditions must be true.
  298. // 1. The child frame window must be active.
  299. if ( (NULL == m_pChildFrame) ||
  300. (false == m_pChildFrame->IsChildFrameActive()) )
  301. return (sc = E_UNEXPECTED);
  302. CAMCView* pAMCView = m_pChildFrame->GetAMCView();
  303. if (NULL == pAMCView)
  304. return (sc = E_UNEXPECTED);
  305. SViewData* pViewData = pAMCView->GetViewData();
  306. if (NULL == pViewData)
  307. return (sc = E_UNEXPECTED);
  308. if (NULL == m_pMainFrame)
  309. return (sc = E_UNEXPECTED);
  310. m_pMenuBar = m_pMainFrame->GetMenuBar();
  311. if (NULL == m_pMenuBar)
  312. return (sc = E_FAIL);
  313. MMC_MenuButtonCollection::iterator it;
  314. for (it = m_MenuButtons.begin(); it != m_MenuButtons.end(); ++it)
  315. {
  316. // 2. The menu button is attached (IControlbar::Attach was called).
  317. if (IsAttached(it->pMenuButtonNotifyClbk) == false)
  318. continue;
  319. // 3. The button is not already added.
  320. if (FALSE == m_pMenuBar->IsButtonHidden(it->nCommandIDFromMenuBar))
  321. continue;
  322. BOOL bHidden = FALSE;
  323. if (false == pViewData->IsSnapinMenusAllowed())
  324. bHidden = TRUE;
  325. it->nCommandIDFromMenuBar =
  326. m_pMenuBar->InsertMenuButton((LPCTSTR)it->lpButtonText.data(),
  327. bHidden || !(it->CanShowMenu()) );
  328. // In user mode there are no menus so this assert is not valid.
  329. // ASSERT(-1 != it->nCommandIDFromMenuBar);
  330. }
  331. return (sc);
  332. }
  333. //+-------------------------------------------------------------------
  334. //
  335. // Member: ScNotifyMenuClick
  336. //
  337. // Synopsis: A menu button is clicked. Notify appropriate owner
  338. // to display a menu.
  339. //
  340. // Arguments:
  341. // [nCommandID] - Command ID
  342. // [pt] - display co-ordinates for popup menu.
  343. //
  344. // Returns: SC
  345. //
  346. //--------------------------------------------------------------------
  347. SC CMenuButtonsMgrImpl::ScNotifyMenuClick(const INT nCommandID, const POINT& pt)
  348. {
  349. DECLARE_SC(sc, _T("CMenuButtonsMgrImpl::ScNotifyMenuClick"));
  350. CAMCView* pAMCView = NULL;
  351. MMC_MenuButtonCollection::iterator it;
  352. // Get the MenuButton data.
  353. it = GetMMCMenuButton( nCommandID );
  354. if (it == m_MenuButtons.end())
  355. return (sc = E_FAIL);
  356. pAMCView = m_pChildFrame->GetAMCView();
  357. if (NULL == pAMCView)
  358. return (sc = E_FAIL);
  359. // This is snapin owned menu, so get the
  360. // selected HNODE, lParam (if result item)
  361. // MENUBUTTONDATA.
  362. HNODE hNode;
  363. bool bScope;
  364. LPARAM lParam;
  365. MENUBUTTONDATA menuButtonData;
  366. // Get the details about the selected item.
  367. sc = pAMCView->ScGetFocusedItem (hNode, lParam, bScope);
  368. if (sc)
  369. return sc;
  370. menuButtonData.idCommand = it->idCommand;
  371. menuButtonData.x = pt.x;
  372. menuButtonData.y = pt.y;
  373. // Notify snapin about the click
  374. if (NULL == it->pMenuButtonNotifyClbk)
  375. return (sc = E_UNEXPECTED);
  376. sc = it->pMenuButtonNotifyClbk->ScNotifyMenuBtnClick(hNode, bScope, lParam, menuButtonData);
  377. if (sc)
  378. return sc;
  379. return (sc);
  380. }
  381. //+-------------------------------------------------------------------
  382. //
  383. // Member: ScAttachMenuButton
  384. //
  385. // Synopsis: Attach the menu buttons object (this object corresponds
  386. // to the IMenuButton object exposed to the snapin).
  387. //
  388. // Arguments:
  389. // [pMenuBtnNotifyClbk] - Notify callback for menu button click.
  390. //
  391. // Returns: SC
  392. //
  393. //--------------------------------------------------------------------
  394. SC CMenuButtonsMgrImpl::ScAttachMenuButton (CMenuButtonNotify* pMenuBtnNotifyClbk)
  395. {
  396. DECLARE_SC(sc, _T("CMenuButtonsMgrImpl::ScAttachMenuButton"));
  397. MMC_AttachedMenuButtons::iterator it = m_AttachedMenuButtons.find(pMenuBtnNotifyClbk);
  398. if (m_AttachedMenuButtons.end() != it)
  399. {
  400. // Already attached, nothing wrong calling twice, return S_FALSE.
  401. return (sc = S_FALSE);
  402. }
  403. // Add the button to the set.
  404. std::pair<MMC_AttachedMenuButtons::iterator, bool> rc =
  405. m_AttachedMenuButtons.insert(pMenuBtnNotifyClbk);
  406. if (false == rc.second)
  407. return (sc = E_FAIL);
  408. // The menu buttons may already be added (without calling
  409. // IControlbar::Attach)
  410. // So give a chance for those buttons that are already added
  411. // but just now attached to get themself added to the main menu.
  412. sc = ScAddMenuButtonsToMainMenu ();
  413. if (sc)
  414. return sc;
  415. return (sc);
  416. }
  417. //+-------------------------------------------------------------------
  418. //
  419. // Member: ScDetachMenuButton
  420. //
  421. // Synopsis: Detach the menu buttons object (this object corresponds
  422. // to the IMenuButton object exposed to the snapin).
  423. //
  424. // Arguments:
  425. // [pMenuBtnNotifyClbk] - Notify callback for menu button click.
  426. //
  427. // Returns: SC
  428. //
  429. // Note : Detach removes the menu buttons and destroys the object.
  430. // So to re-create the menu button the snapin should again
  431. // do IMenuButton::AddButton and IControlbar::Attach.
  432. // This is how it is designed in mmc 1.0
  433. //
  434. //--------------------------------------------------------------------
  435. SC CMenuButtonsMgrImpl::ScDetachMenuButton (CMenuButtonNotify* pMenuBtnNotifyClbk)
  436. {
  437. DECLARE_SC(sc, _T("CMenuButtonsMgrImpl::ScDetachMenuButton"));
  438. if ( (NULL == m_pChildFrame) ||
  439. (false == m_pChildFrame->IsChildFrameActive()))
  440. return (sc = S_OK); // When child-frame is deactivated the menus are removed.
  441. // Make sure the menu is currently attached.
  442. if (m_AttachedMenuButtons.end() ==
  443. m_AttachedMenuButtons.find(pMenuBtnNotifyClbk))
  444. // This Menu Button is not attached.
  445. return (sc = E_UNEXPECTED);
  446. if ( (NULL == m_pMainFrame) ||
  447. (NULL == m_pMenuBar) )
  448. return (sc = E_UNEXPECTED);
  449. MMC_MenuButtonCollection::iterator it = m_MenuButtons.begin();
  450. while ( it != m_MenuButtons.end())
  451. {
  452. if (it->pMenuButtonNotifyClbk == pMenuBtnNotifyClbk)
  453. {
  454. BOOL bRet = FALSE;
  455. // Remove the menu button from Main Menu.
  456. if (-1 != it->nCommandIDFromMenuBar)
  457. bRet = m_pMenuBar->DeleteMenuButton(it->nCommandIDFromMenuBar);
  458. // The CMenubar removes all the menus when childframe is de-activated.
  459. // So DeleteMenuButton will fail if the button does not exist.
  460. // Therefore we do not check below error.
  461. // if (FALSE == bRet)
  462. // return (sc = E_FAIL);
  463. // Delete the object in our data structure
  464. it = m_MenuButtons.erase(it);
  465. }
  466. else
  467. ++it;
  468. }
  469. // Delete the IMenuButton ref from the set.
  470. m_AttachedMenuButtons.erase(pMenuBtnNotifyClbk);
  471. return (sc);
  472. }
  473. //+-------------------------------------------------------------------
  474. //
  475. // Member: ScToggleMenuButton
  476. //
  477. // Synopsis: Hide or Show the given menu buttons.
  478. //
  479. // Arguments:
  480. // [bShow] - Show or Hide the menu buttons.
  481. //
  482. // Returns: SC
  483. //
  484. //--------------------------------------------------------------------
  485. SC CMenuButtonsMgrImpl::ScToggleMenuButton(BOOL bShow)
  486. {
  487. DECLARE_SC(sc, _T("CMenuButtonsMgrImpl::ScToggleMenuButton"));
  488. if ( (NULL == m_pChildFrame) ||
  489. (false == m_pChildFrame->IsChildFrameActive()) ||
  490. (NULL == m_pMenuBar) )
  491. return (sc = E_UNEXPECTED);
  492. // Go thro all the menu buttons added.
  493. MMC_MenuButtonCollection::iterator it;
  494. for (it = m_MenuButtons.begin(); it != m_MenuButtons.end(); ++it)
  495. {
  496. BOOL bRetVal = TRUE; // Init to true so that failure (false) can be checked below.
  497. // Toggle the menu hidden status. If the menu is
  498. // un-hidden then check if it is allowed.
  499. bRetVal = m_pMenuBar->HideButton(it->nCommandIDFromMenuBar, bShow ? !(it->CanShowMenu()) : TRUE);
  500. if (FALSE == bRetVal)
  501. return (sc = E_FAIL);
  502. }
  503. return (sc);
  504. }
  505. //+-------------------------------------------------------------------
  506. //
  507. // Member: ScDisableMenuButtons
  508. //
  509. // Synopsis: Disable all the menubuttons.
  510. //
  511. // Arguments: None.
  512. //
  513. // Returns: SC
  514. //
  515. //--------------------------------------------------------------------
  516. SC CMenuButtonsMgrImpl::ScDisableMenuButtons()
  517. {
  518. DECLARE_SC(sc, _T("CMenuButtonsMgrImpl::ScDisableMenuButtons"));
  519. if ( (NULL == m_pChildFrame) ||
  520. (false == m_pChildFrame->IsChildFrameActive()) ||
  521. (NULL == m_pMenuBar) )
  522. return (sc = E_UNEXPECTED);
  523. // Go thro all the menu buttons added.
  524. MMC_MenuButtonCollection::iterator it;
  525. for (it = m_MenuButtons.begin(); it != m_MenuButtons.end(); ++it)
  526. {
  527. if (m_pMenuBar->IsButtonEnabled(it->nCommandIDFromMenuBar))
  528. {
  529. BOOL bRet = m_pMenuBar->EnableButton(it->nCommandIDFromMenuBar, false);
  530. if (FALSE == bRet)
  531. return (sc = E_FAIL);
  532. }
  533. }
  534. return (sc);
  535. }
  536. //+-------------------------------------------------------------------
  537. //
  538. // Member: GetMMCMenuButton
  539. //
  540. // Synopsis: Given the Notify callback and button command id get the button
  541. //
  542. // Arguments:
  543. // [pMenuBtnNotifyClbk] - Callback for Menu click.
  544. // [idCommand] - Button command id.
  545. //
  546. // Returns: iterator to MMC_MenuButtonCollection
  547. //
  548. //--------------------------------------------------------------------
  549. MMC_MenuButtonCollection::iterator
  550. CMenuButtonsMgrImpl::GetMMCMenuButton( CMenuButtonNotify* pMenuBtnNotifyClbk,
  551. INT idCommand)
  552. {
  553. MMC_MenuButtonCollection::iterator it;
  554. for (it = m_MenuButtons.begin(); it != m_MenuButtons.end(); ++it)
  555. {
  556. if ( (it->pMenuButtonNotifyClbk == pMenuBtnNotifyClbk) &&
  557. (it->idCommand == idCommand) )
  558. {
  559. return it;
  560. }
  561. }
  562. return m_MenuButtons.end();
  563. }
  564. //+-------------------------------------------------------------------
  565. //
  566. // Member: GetMMCMenuButton
  567. //
  568. // Synopsis: Given the command id get the button
  569. //
  570. // Arguments:
  571. // [nCommandID] - Command ID.
  572. //
  573. // Returns: iterator to MMC_MenuButtonCollection
  574. //
  575. //--------------------------------------------------------------------
  576. MMC_MenuButtonCollection::iterator
  577. CMenuButtonsMgrImpl::GetMMCMenuButton( INT nCommandID)
  578. {
  579. MMC_MenuButtonCollection::iterator it;
  580. for (it = m_MenuButtons.begin(); it != m_MenuButtons.end(); ++it)
  581. {
  582. if ( it->nCommandIDFromMenuBar == nCommandID )
  583. {
  584. return it;
  585. }
  586. }
  587. return m_MenuButtons.end();
  588. }
  589. //+-------------------------------------------------------------------
  590. //
  591. // Member: IsAttached
  592. //
  593. // Synopsis: Given the notify callback, check if the MenuButtons
  594. // object is attached or not.
  595. //
  596. // Arguments:
  597. // [pMenuBtnNotifyClbk] - Notify callback.
  598. //
  599. // Returns: bool
  600. //
  601. //--------------------------------------------------------------------
  602. bool CMenuButtonsMgrImpl::IsAttached( CMenuButtonNotify* pMenuBtnNotifyClbk)
  603. {
  604. MMC_AttachedMenuButtons::iterator it = m_AttachedMenuButtons.find(pMenuBtnNotifyClbk);
  605. if (m_AttachedMenuButtons.end() != it)
  606. return true;
  607. return false;
  608. }