Print Page | Close Window

Menu Bar Issue.

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=6734
Printed Date: 03 March 2025 at 10:46pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Menu Bar Issue.
Posted By: Makarand
Subject: Menu Bar Issue.
Date Posted: 26 March 2007 at 11:06am
 

Hi,

 

I am facing the problem with the menu.

I am trying to replace the codejock lib 4.2 to 10.4.2. I have created menu by using following code.

 

 // Initialize the command bars
    if (!InitCommandBars())
        return -1;

    // Get a pointer to the command bars object.
    pCommandBars = GetCommandBars();
    if(pCommandBars == NULL)
    {
        TRACE0("Failed to create command bars object.\n");
        return -1;      // fail to create
    }

    // Add the menu bar
    m_wndMenuBar = (CXTPMenuBar*)pCommandBars->SetMenu(
        _T("Menu Bar"),
IDR_MAINFRAME);
    if(m_wndMenuBar == NULL)
    {
        TRACE0("Failed to create menu bar.\n");
        return -1;      // fail to create
    }

 

Now the problem with the command routing of menu bar, When I select the "File" menu from the menu bar, all the menus from the "File" like "New", "Open"... get fired.

 

I am confused for this misbehavior, If I remove the code and replace the old code as follow

 

 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
 }

 

It is working fine.

 

Please help for the Issue

 
Thank You,



Replies:
Posted By: Oleg
Date Posted: 26 March 2007 at 11:59am

Hi

May be you have some update handler that can delete these commands...


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


Posted By: saket
Date Posted: 27 March 2007 at 9:16am

Hi ,

What we need to do for this, So that command do not get deleted.


Thanks,
Saket Kumar.



Posted By: Oleg
Date Posted: 27 March 2007 at 10:53am
Hi,
 
I don't know what you do to delete it, so I don't know how to prevent.
 
Send whole project to mailto:support@codejock.com - support@codejock.com and I will suggest you what to change.


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


Posted By: saket
Date Posted: 28 March 2007 at 8:22am

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:

 

MAINFRAME.CPP

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.

 

MAINFRAME.CPP

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.

 

 



Posted By: saket
Date Posted: 28 March 2007 at 9:26am
What is the class for below in codejock 10.4.2
 
CXTMDIChildWnd / CXTControlBar /



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