![]() |
Issue in Menu with Code Jock10.4.2 Integration |
Post Reply
|
| Author | |
KumarCJ
Groupie
Joined: 02 April 2007 Location: India Status: Offline Points: 96 |
Post Options
Thanks(0)
Quote Reply
Topic: Issue in Menu with Code Jock10.4.2 IntegrationPosted: 02 April 2007 at 6:26am |
|
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
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 02 April 2007 at 7:35am |
|
Hi,
If you use CommandBars, you will not able to use HMENU. To add/remove controls in menubar/menu you have use CXTPControls methods
pMenuBar->GetControls()->Add or pMenuBar->GetControls()->Remove(i);
see CXTPControls members in symbolReference. check our DynamicPopups sample.
|
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
KumarCJ
Groupie
Joined: 02 April 2007 Location: India Status: Offline Points: 96 |
Post Options
Thanks(0)
Quote Reply
Posted: 02 April 2007 at 8:34am |
|
Hi,
We do not want to add/remove menu in menubar.
We are having fix menu say File, Edit, View, Customize, Windows, Help.
Lets assume in File Menu, we have OpenDB, Import, Export.... menu items.
Once I clicked on any of the Menu Say File, Edit, View, Customize, Windows, Help all the menu item event get fired.
Once I clicked on File, the DialogBox for OpenDB, Import, Export.... is displayed.
Please let me know why this is happening.
Thanks,
Saket |
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 02 April 2007 at 9:42am |
|
Hi,
try temporary comment all message handlers of CMainframe (instead WM_CREATE) and check if it will work. it have to be something in your code.
Send to support@codejock.com your mainfrm.cpp to check what you do.
|
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |