Print Page | Close Window

Unable to get the HANDLE of Menu

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=6797
Printed Date: 12 November 2025 at 5:46pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Unable to get the HANDLE of Menu
Posted By: KumarCJ
Subject: Unable to get the HANDLE of Menu
Date Posted: 04 April 2007 at 6:52am

Hi,

I have used the follwing code for Menu.

--------------------------------------------
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   //Using CXTPCommandBar -->Derived from CWnd

CXTPCommandBar* pMenuBarCmdBar = pCommandBars->SetMenu(_T   ("Menu Bar"), IDR_MAINFRAME);

if(pMenuBarCmdBar == NULL)
{
   TRACE0("Failed to create menu bar.\n");
   return -1;      // fail to create
}
 
HMENU hMenu = GetMenu()->GetSafeHmenu();
//Problem: [Unable to get the HANDLE of Menu]

}//End of CMainFrame::OnCreate()
--------------------------------------------

Trying to get HANDLE of Menu in "OnCreate" using following code,

HMENU hMenu = GetMenu()->GetSafeHmenu();

But I am unable to get HANDLE.

What is the way to get HANDLE of Menu????

Thanks,
KumarCJ




Replies:
Posted By: Oleg
Date Posted: 05 April 2007 at 2:01am
Hi,
CommandBars don't hold HMENU.
 
To modify Menu/Toolbars use CXTPControls methods.
 
f.e
pMenuBar->GetControls()->Add(..)


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: KumarCJ
Date Posted: 05 April 2007 at 5:57am

Hi,

 

Thanks for reply.

 

I do not want to add or modify the Menu.

 

I need to assign Menu Handle to diffrent shared document template such as Spliter Window, BookView etc...

 

Below code is defind in XYZ.h, for diffrent shared document template

 

CSharedDocTemplate* m_pSplitWindowTempl;        // Split Window
CSharedDocTemplate* m_pBookTempl;                    // Book view

 

The below given code is in OnCreate() of MainFrame.cpp, where we are assigning the Menu handle to diffrent shared document template.

 

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{

 

CXTPMenuBar*  pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME);

    HMENU hMenu = GetMenu()->GetSafeHmenu();

[As you told, since CommandBar dose not hold HMENU, We are not getting hMenu]

 

    CXYZApp * pApp = (CXYZApp *)AfxGetApp();

 

[But we need to assign handle of menu for diffrent shared document template.]

    pApp->m_pSplitWindowTempl->m_hMenuShared = hMenu;
    pApp->m_pBookTempl->m_hMenuShared =
hMenu;

 

}

 

Since we are not getting "hMenu", we are unable to assign it to diffrent shared document template.

 

 

How we can assign handle of menu to diffrent shared document template.

 

Thanks,

KumarCJ




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