Hi,
We are having MDI application.
Previously we were using codejock 4.2. And the code for creation of menu and getting the HANDLE of Menu is as follows:
Header Section:
#include ".\Common\XTPImageManager.h"
//#include <XTImageManager.h> // This path is relative to 'Xtreme Toolkit\Include' folder
//#include <Common.Include/XTAnimationMemDC.h>
In “int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)”
//Create Menu and load it
if (!m_wndMenuBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
//Get the Handle for Menu HMENU hMenu = GetMenu()->GetSafeHmenu();
In the other class say XYZCLS.CPP, we need the CMenu*
Void XYZCLS ::xyzFun()
{
CMenu* ptrMenu;
CMainFrame * pFrame = (CMainFrame *)AfxGetMainWnd();
ptrMenu = pFrame->GetMenu();
[Able to get ptrMenu]
pSubMenu = pMenu->GetSubMenu(nPos); //assume nPos = 0
}
This was the code for CodeJock 4.2 and that is working fine.
Here is the sample code for what I want to do using codejock 10.4.2.
Header Section:
#include ".\Common\XTPImageManager.h"
//#include <XTImageManager.h> // This path is relative to 'Xtreme Toolkit\Include' folder
//#include <Common.Include/XTAnimationMemDC.h>
In “int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)”
//Create Menu and load it
/*if (!m_wndMenuBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME))
{
TRACE0("Failed to create menubar\n");
return -1; // fail to create
}
*/
-------------------Replaced the above code with
// Initialize the command bars
if (!InitCommandBars())
return -1;
pCommandBars = GetCommandBars();
// Add the menu bar : CALL "SetMenu()" member to create menu bar RETURN CXTPMenuBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME);
//Tried but not working
//pMenuBar->LoadMenuBar(IDR_MAINFRAME);
//Get the Handle for Menu HMENU hMenu = GetMenu()->GetSafeHmenu();
[In the hMenu, we are not getting handle to menu],
In the other class say XYZCLS.CPP, we need the CMenu*
Void XYZCLS ::xyzFun()
{
CMenu* ptrMenu;
CMainFrame * pFrame = (CMainFrame *)AfxGetMainWnd();
ptrMenu = pFrame->GetMenu();
[In the ptrMenu, we are not getting pointer to menu],
Since we are not able to get pMenu, the below line break the execution,
pSubMenu = pMenu->GetSubMenu(nPos); //assume nPos = 0
The above line is breaking because “pMenu”.
}
If are ignoring it and trying to open any menu, the application is firing command for the entire menu item.
I had changed the “MainFrame.h”, Given Below
//class CMainFrame : public CMDIFrameWnd
class CMainFrame : public CXTPMDIFrameWnd
For the Child Frame Window: //No Change
class CChildFrame : public CMDIChildWnd
Since “CXTPMDIChildWnd” is not there for codejock 10.4.2. CChildFrame derivation is as it.
This is the issue. Please help me out.
Thanks in advance.
Saket Kumar.
|