Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Menu Bar Issue.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Menu Bar Issue.

 Post Reply Post Reply
Author
Message
Makarand View Drop Down
Senior Member
Senior Member
Avatar

Joined: 27 February 2007
Location: India
Status: Offline
Points: 140
Post Options Post Options   Thanks (0) Thanks(0)   Quote Makarand Quote  Post ReplyReply Direct Link To This Post Topic: Menu Bar Issue.
    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,
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 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
Back to Top
saket View Drop Down
Newbie
Newbie


Joined: 15 March 2007
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote saket Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 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 support@codejock.com and I will suggest you what to change.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
saket View Drop Down
Newbie
Newbie


Joined: 15 March 2007
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote saket Quote  Post ReplyReply Direct Link To This Post 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.

 

 

Back to Top
saket View Drop Down
Newbie
Newbie


Joined: 15 March 2007
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote saket Quote  Post ReplyReply Direct Link To This Post Posted: 28 March 2007 at 9:26am
What is the class for below in codejock 10.4.2
 
CXTMDIChildWnd / CXTControlBar /
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.031 seconds.