Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Unable to get the HANDLE of Menu
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Unable to get the HANDLE of Menu

 Post Reply Post Reply
Author
Message
KumarCJ View Drop Down
Groupie
Groupie
Avatar

Joined: 02 April 2007
Location: India
Status: Offline
Points: 96
Post Options Post Options   Thanks (0) Thanks(0)   Quote KumarCJ Quote  Post ReplyReply Direct Link To This Post Topic: Unable to get the HANDLE of Menu
    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

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


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: 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
Back to Top
KumarCJ View Drop Down
Groupie
Groupie
Avatar

Joined: 02 April 2007
Location: India
Status: Offline
Points: 96
Post Options Post Options   Thanks (0) Thanks(0)   Quote KumarCJ Quote  Post ReplyReply Direct Link To This Post 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

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.043 seconds.