Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - "OnInitMenuPopup" can not work, why?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

"OnInitMenuPopup" can not work, why?

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


Joined: 22 April 2004
Status: Offline
Points: 95
Post Options Post Options   Thanks (0) Thanks(0)   Quote freehawk Quote  Post ReplyReply Direct Link To This Post Topic: "OnInitMenuPopup" can not work, why?
    Posted: 22 July 2004 at 3:09am

Hello :

I added "OnInitMenuPopup" to my mainframe inherited from CXTPMDIFrameWnd, but after clicked the menu bar, the function was not called, Please help me, is it why?

Thank you.

-Freehawk

 

Back to Top
BruceW View Drop Down
Newbie
Newbie


Joined: 05 April 2006
Location: United Kingdom
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote BruceW Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2006 at 4:05am
Hi,

I have the same problem.  My menus are dynamic and need to be modified depending on the MDI child view selected. 

Can anbody give me a different solution.

Any help appreciated.

Thanks,

Bruce.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2006 at 7:45am

Hello,

I guess you tring to catch OnInitMenuPopup in MDI child? It must be catched inMDI parent.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
BruceW View Drop Down
Newbie
Newbie


Joined: 05 April 2006
Location: United Kingdom
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote BruceW Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2006 at 9:02am
No, I catch it in tne MDI parant.  It used to work before subclassing off CXTPMDIFrameWnd, but now it does not.

Bruce.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2006 at 10:03am

ohh. i see now.

by OnInitMenuPopup  I mean CommandBars version of this function

 

from Notifications sample:

 

ON_XTP_INITCOMMANDSPOPUP()

...

void CMainFrame::OnInitCommandsPopup(CXTPPopupBar* pCommandBar)
{
 // get the list of commands for the popup.
 CXTPControls* pCommandList = pCommandBar->GetControls();

 // Remove "New" menu item from the File menu.
 CXTPControl* pCommandNew = pCommandList->FindControl(
  xtpControlButton, ID_FILE_NEW, TRUE, FALSE);
 if (pCommandNew)
 {
  pCommandList->Remove(pCommandNew);
 }

 // Rename menu item "Save" to "Save Document".
 CXTPControl* pCommandSave = pCommandList->FindControl(
  xtpControlButton, ID_FILE_SAVE, TRUE, FALSE);
 if (pCommandSave)
 {
  CWnd* pWnd = MDIGetActive();
  CString strCaption;
  if (pWnd) pWnd->GetWindowText(strCaption);

  pCommandSave->SetCaption("&Save " + strCaption);
 }

 // Rename menu item "Print..." to "Print Document...".
 CXTPControl* pCommandPrint = pCommandList->FindControl(
  xtpControlButton, ID_FILE_PRINT, TRUE, FALSE);
 if (pCommandPrint)
 {
  CWnd* pWnd = MDIGetActive();
  CString strCaption;
  if (pWnd) pWnd->GetWindowText(strCaption);

  pCommandPrint->SetCaption("&Print " + strCaption +"...");
 }

 // Sample of dynamic creation. Recommended to make it in OnCreateControl handler.
 CXTPControl* pControlIcons = pCommandList->FindControl(
  xtpControlButton, ID_VIEW_ICONS, TRUE, FALSE);
 if (pControlIcons)
 {
  CXTPControlPopup* pPopup = (CXTPControlPopup*)pControlIcons->GetControls()->SetCo ntrolType(pControlIcons, xtpControlPopup);
  pPopup->SetFlags(xtpFlagManualUpdate);

  CXTPPopupToolBar* pPopupBar = CXTPPopupToolBar::CreatePopupToolBar(GetCommandBars());
  pPopupBar->LoadToolBar(IDR_MAINFRAME);
  pPopupBar->SetWidth(200);

  pPopup->SetCommandBar(pPopupBar);
  pPopupBar->InternalRelease();

 }

 

 // Combo box's List bar.
 if (pCommandBar->GetPosition() == xtpBarListBox)
 {
  CXTPControlComboBox* pControl = DYNAMIC_DOWNCAST(CXTPControlComboBox, pCommandBar->GetControlPopup());
  ASSERT(pControl != NULL);

  pControl->ResetContent();

  int nID = AFX_IDM_FIRST_MDICHILD;

  HWND hWndChild = ::GetDlgItem(m_hWndMDIClient, nID);
  while (hWndChild)
  {
   TCHAR lpText[256];
   ::GetWindowText(hWndChild, lpText, 256);
   pControl->AddString(lpText);


   hWndChild = ::GetDlgItem(m_hWndMDIClient, ++nID);
  }

 }
}

 

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
BruceW View Drop Down
Newbie
Newbie


Joined: 05 April 2006
Location: United Kingdom
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote BruceW Quote  Post ReplyReply Direct Link To This Post Posted: 10 April 2006 at 4:34am
Hi,

Solution works, thanks, though it is not quite the solution I was looking for.

The requirement I have is to be able to modify the menus depending on the current selected view.  Remember, the contents of the menus are dynamic, and so do not have specific IDs.

On the first call to OnInitCommandsPopup the menu gets changed.  However on the next call I would like the menu to be according to the original template (which has identifiable markers which I look for), so I can do the necessary changes again (according to the current selection), rather than trying to figure out what changes I need to undo first.  The key point in the second and subsequent calls is that my original markers have been removed (they are dummy) and so it is difficult to know what to undo.

Any ideas?

Thanks,

Bruce.
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.203 seconds.