Print Page | Close Window

CXTPMenuBar in CWnd derived CHILD window

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=11019
Printed Date: 28 February 2025 at 4:23pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPMenuBar in CWnd derived CHILD window
Posted By: BobWansink
Subject: CXTPMenuBar in CWnd derived CHILD window
Date Posted: 13 June 2008 at 5:27am
Hi!

I've been experimenting with MFC and Codejock for a while now, and ran into a little trouble. I've got a CWnd derived panel on my SDI application, and I'd like to a menu to it. I've tried to add it using MFC's CWnd::SetMenu, and found out that the function fails, since the panel is created with windowstyle WS_CHILD. GetLastError then produces "Child windows cannot have menus."

Can I use Codejock to add the menu? if i add a CXTPMenuBar to my CWnd panel, can i use CJ to load and set the menu?

Thanks!

Bob




Replies:
Posted By: Oleg
Date Posted: 13 June 2008 at 6:34am
Hi,
 
Yes, you can add CXTPMenuBar. See DialogSample or GUI_VisualStudio, with same methods you can add menu for any window.


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


Posted By: BobWansink
Date Posted: 16 June 2008 at 3:10am
Hi Oleg,

I still seem to be hitting a brick wall. Perhaps I'm missing something here...

I'm trying to add the CXTPMenuBar to a CWnd derived panel, not CFrameWnd (or CXTFrameWnd). As such, functions like InitCommandBars or GetCommandBars won't work.

Does the window have to be CFrameWnd derived, or is CWnd derived enough?


Posted By: Oleg
Date Posted: 17 June 2008 at 12:43am
Hi,
 
See code of Samples\ToolkitPro\Advanced\HeroesView.cpp
 
you need derive from CXTPCommandBarsSiteBase<CWnd> to add InitCommandBars or GetCommandBars methods.


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


Posted By: BobWansink
Date Posted: 17 June 2008 at 3:48am
Thanks Oleg! That was just what I needed to make it work. The heroesView.cpp file was very helpful.

Great support!

Bob


Posted By: BobWansink
Date Posted: 24 November 2008 at 9:19am
Hi Oleg,

I've been able to make my CMenu appear. Thanks for your help! I still have one problem though. The rest of my program doesn't seem to realize that the menubar is there... After window creation i use


  pSubMenu->LoadMenu(&menu);
  pSubMenu->RefreshMenu();
  RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposDefault);

to insert the menu into the panel.

The menubar is added, but not like a standard menubar. I'd expected the menubar to be placed above the panel, instead of inside it. Now, our own grid is drawn above it. This means that hovering the mouse near coordinate 0,0 of the panel makes a menuitem 'appear' over our grid, and clicking it causes the entire menubar to be redrawn over the grid.

How do i make the menu behave like a 'normal' menu?


Thanks in advance,

Bob



Posted By: Oleg
Date Posted: 25 November 2008 at 2:37am

Hi,

You have manually reposition all child controls.


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


Posted By: mgampi
Date Posted: 25 November 2008 at 5:41am
Hi;
I did it this way in my OnSize() handler:

CMyWnd::OnSize(...) {
    CWnd::OnSize(nType, cx, cy);   
    CXTPClientRect rcClient(this);
    if (cx>0 || cy>0) {
        RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, 0, 0, &rcClient);
        RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery, &rcClient, &rcClient);
    }
    if (tree_.GetSafeHwnd()!=0) {    // This is my only child
        tree_.MoveWindow(rcClient);
    }
}


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: BobWansink
Date Posted: 25 November 2008 at 6:29am
Hi Oleg and Martin,

thanks! That clarified a lot!

Bob



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