|
Hi,
Our application is MDI application using CodeJock 4.2.
For Menu creation using code jock 4.2, we are using follwing code in "int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)"
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 }
For getting the handle of menu, we are using follwing code in "int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)"
HMENU hMenu = GetMenu()->GetSafeHmenu();
In other class say "ABC" , we are having a function say "XYZMenu"
void XYZMenu
{
CMenu* pMenu;
CMenu * pSubMenu;
int nPos;
CMainFrame * pFrame = (CMainFrame *)AfxGetMainWnd(); ASSERT_VALID( pFrame );
if ((pMenu = pFrame->GetMenu()) == NULL) return FALSE;
nPos = GetMyMenuPosition(TOPMENU_FILE);
pSubMenu = pMenu->GetSubMenu(nPos);
}
The above code is working fine with Code Jock 4.2. MENU is working fine.
When I tried to to integrate it with CodeJock 10.4.2.
For Menu creation using code jock 10.4.2, we are using follwing code in "int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)"
Commented the old code
/*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 }*/
Added the follwing code
// Initialize the command bars if (!InitCommandBars()) return -1;
CXTPCommandBars* pCommandBars = GetCommandBars();
CXTPMenuBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"),IDR_MAINFRAME);
For getting the handle of menu, we are using the same code what we had used in application with Code Jock 4.2 in "int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)"
HMENU hMenu = GetMenu()->GetSafeHmenu();
***
But in this case we are not getting the handle of menu
QUESTION 1:
After writing the new code using "SetMenu" for menu creation HOW we can get the Handle of Menu. So that we can pass the handle to required place.
-----------------
In other class say "ABC" , we are having same function say "XYZMenu"
void XYZMenu
{
CMenu* pMenu;
CMenu * pSubMenu;
int nPos;
CMainFrame * pFrame = (CMainFrame *)AfxGetMainWnd(); ASSERT_VALID( pFrame );
if ((pMenu = pFrame->GetMenu()) == NULL) return FALSE;
[Note: Here "pMenu" is having NULL value when we used "SetMenu() in MainFrame.cpp"]
nPos = GetMyMenuPosition(TOPMENU_FILE);
pSubMenu = pMenu->GetSubMenu(nPos);
}
QUESTION 2:
How we can get the CMenu* in the "XYZMenu()".
After adding the new code, If user clicks on say "File" Menu, the application is displaying all the menu item's dialogboxes related with menu items. It is not displaying the List of menu item so that user does not have control to select menu item from "File" menu.
Same thing is happing with all other menu.
Please help me out.
Thanks,
KumarCJ
|