Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - CXTPMenuBar in CWnd derived CHILD window
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPMenuBar in CWnd derived CHILD window

 Post Reply Post Reply
Author
Message
BobWansink View Drop Down
Groupie
Groupie
Avatar

Joined: 24 January 2008
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote BobWansink Quote  Post ReplyReply Direct Link To This Post Topic: CXTPMenuBar in CWnd derived CHILD window
    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

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: 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
Back to Top
BobWansink View Drop Down
Groupie
Groupie
Avatar

Joined: 24 January 2008
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote BobWansink Quote  Post ReplyReply Direct Link To This Post 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?
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: 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
Back to Top
BobWansink View Drop Down
Groupie
Groupie
Avatar

Joined: 24 January 2008
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote BobWansink Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
BobWansink View Drop Down
Groupie
Groupie
Avatar

Joined: 24 January 2008
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote BobWansink Quote  Post ReplyReply Direct Link To This Post 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

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: 25 November 2008 at 2:37am

Hi,

You have manually reposition all child controls.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
BobWansink View Drop Down
Groupie
Groupie
Avatar

Joined: 24 January 2008
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote BobWansink Quote  Post ReplyReply Direct Link To This Post Posted: 25 November 2008 at 6:29am
Hi Oleg and Martin,

thanks! That clarified a lot!

Bob
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.043 seconds.