Print Page | Close Window

"OnInitMenuPopup" can not work, why?

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=968
Printed Date: 21 December 2024 at 8:23pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: "OnInitMenuPopup" can not work, why?
Posted By: freehawk
Subject: "OnInitMenuPopup" can not work, why?
Date 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

 




Replies:
Posted By: BruceW
Date 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.


Posted By: Oleg
Date 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


Posted By: BruceW
Date 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.


Posted By: Oleg
Date 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


Posted By: BruceW
Date 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.



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