Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - How to get submenu control?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to get submenu control?

 Post Reply Post Reply
Author
Message
hikaroute View Drop Down
Groupie
Groupie


Joined: 05 September 2007
Status: Offline
Points: 51
Post Options Post Options   Thanks (0) Thanks(0)   Quote hikaroute Quote  Post ReplyReply Direct Link To This Post Topic: How to get submenu control?
    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.
 
Back to Top
Simon HB9DRV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 July 2005
Location: Switzerland
Status: Offline
Points: 458
Post Options Post Options   Thanks (0) Thanks(0)   Quote Simon HB9DRV Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.