Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Issue in Menu with Code Jock10.4.2 Integration
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Issue in Menu with Code Jock10.4.2 Integration

 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: Issue in Menu with Code Jock10.4.2 Integration
    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
 
 
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: 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
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: 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
 
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: 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
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.066 seconds.