Print Page | Close Window

How to get submenu control?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=9664
Printed Date: 14 November 2025 at 7:21pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to get submenu control?
Posted By: hikaroute
Subject: How to get submenu control?
Date Posted: 22 February 2008 at 3:37am
Hi oleg,
again that I have problem to you.  But this problem is the big for me.  Now I need to get the sub menu control from my main menu. like this.
 
&File
- &New
- &Open
- &Save
- E&xit
 
I make menu from XTPMenuBar.
 
Now I want to get the control that contain submenu like "New" or "Open" to set the new icon on it, change name or set enable/disable.
 
Thank you so much.
 



Replies:
Posted By: Simon HB9DRV
Date Posted: 22 February 2008 at 3:47am
Here's what I do, formatting is lost when pasting here :-(
 
//
// Popup a menu.
//
void CMainFrame::TrackPopupMenu(const CString& strTitle,
        const CPoint&  point)
{
 CXTPCommandBars* pCommandBars     = MainFrame().GetCommandBars();
 CXTPMenuBar*  pMenuBar         = pCommandBars->GetMenuBar();
 int     nMenuCount       = pMenuBar->GetControlCount();
 int     nIndex           = 0;
 CXTPCommandBar*  pChildCommandBar = NULL;
 //
 // Find menu.
 //
 for (nIndex = 0; nIndex < nMenuCount; nIndex++)
 {
  CXTPControl* pControl   = pMenuBar->GetControl(nIndex);
  CString   strCaption = pControl->GetCaption();
  TRACE(_T("Menu %d [%s]\n"), nIndex, strCaption);
  strCaption.Remove(_T('&'));
  if (strCaption.CompareNoCase(strTitle) == 0)
  {
   pChildCommandBar = pControl->GetCommandBar();
   break;
  }
 }
 //
 // Owner.
 //
 if (pChildCommandBar != NULL)
 {
  CWnd* pWndPopupOwner = &MainFrame();
  CXTPCommandBars::TrackPopupMenu((CXTPPopupBar*)pChildCommandBar,
          TPM_RIGHTBUTTON,
          point.x,
          point.y,
          pWndPopupOwner,
          0,
          0);
 }
}
 


-------------
Simon HB9DRV



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net