Print Page | Close Window

Issue in Menu with Code Jock10.4.2 Integration

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


Topic: Issue in Menu with Code Jock10.4.2 Integration
Posted By: KumarCJ
Subject: Issue in Menu with Code Jock10.4.2 Integration
Date Posted: 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
 
 



Replies:
Posted By: Oleg
Date 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


Posted By: KumarCJ
Date 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
 


Posted By: Oleg
Date 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 mailto:support@codejock.com - support@codejock.com your mainfrm.cpp to check what you do.


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



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