![]() |
CXTPMenuBar in CWnd derived CHILD window |
Post Reply ![]() |
Author | |
BobWansink ![]() Groupie ![]() ![]() Joined: 24 January 2008 Status: Offline Points: 59 |
![]() ![]() ![]() ![]() ![]() 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 |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
BobWansink ![]() Groupie ![]() ![]() Joined: 24 January 2008 Status: Offline Points: 59 |
![]() ![]() ![]() ![]() ![]() |
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? |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
BobWansink ![]() Groupie ![]() ![]() Joined: 24 January 2008 Status: Offline Points: 59 |
![]() ![]() ![]() ![]() ![]() |
Thanks Oleg! That was just what I needed to make it work. The heroesView.cpp file was very helpful.
Great support! Bob |
|
![]() |
|
BobWansink ![]() Groupie ![]() ![]() Joined: 24 January 2008 Status: Offline Points: 59 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi, You have manually reposition all child controls.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
mgampi ![]() Senior Member ![]() ![]() Joined: 14 July 2003 Status: Offline Points: 1201 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
BobWansink ![]() Groupie ![]() ![]() Joined: 24 January 2008 Status: Offline Points: 59 |
![]() ![]() ![]() ![]() ![]() |
Hi Oleg and Martin,
thanks! That clarified a lot! Bob |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |