Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - CMenu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CMenu

 Post Reply Post Reply
Author
Message
Kenneth View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 May 2004
Location: United States
Status: Offline
Points: 256
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kenneth Quote  Post ReplyReply Direct Link To This Post Topic: CMenu
    Posted: 17 June 2004 at 11:12am

We used the following code in the Xtreme Toolkit to allow a user to execute a menu item from a user defined "Smart Button".  How does one search the new Xtreme Toolkit Pro menu and submenus?

 int AppFindMenuItem(CMenu *Menu,LPCTSTR MenuString)
 {
 ASSERT(Menu);
 ASSERT(::IsMenu(Menu->GetSafeHmenu()));
 CString mitem = MenuString;
 int count = Menu->GetMenuItemCount();
 mitem.Replace(_T("&"),_T(""));
 for(int i = 0; i < count; i++)
      {
      CString str;
      if(Menu->GetMenuString(i,str,MF_BYPOSITION))
           {
           str.Replace(_T("&"),_T(""));
           if(str.Compare(mitem) == 0)
                 return(Menu->GetMenuItemID(i));
           }
      }
 return(-1);
 }


 if(code == '~')
      {
      // Do Menu
      int i,j,k;
      CMenu *pMenu;
      pMenu = (CMenu *)(((CMainFrame*)AfxGetApp()->m_pMainWnd)->GetMenu());
      if(pMenu)
           {
           j = pMenu->GetMenuItemCount();
           for(i = 0; i < j; ++i)
                 {
                 k = AppFindMenuItem(pMenu->GetSubMenu(i),app);
                 if(k > 0)
                      {
                      PostMessage(WM_COMMAND,k);
                      pView->TermSetFocus();
                      return;
                      }
                 }
           }
      return;
      }

 

Back to Top
Kenneth View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 May 2004
Location: United States
Status: Offline
Points: 256
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kenneth Quote  Post ReplyReply Direct Link To This Post Posted: 17 June 2004 at 1:30pm
Disregard, I figured it out.
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.174 seconds.