Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - LoadDesignerBars
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

LoadDesignerBars

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

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Topic: LoadDesignerBars
    Posted: 19 April 2004 at 7:07pm

Can you use LoadDesignerBars with an MFC appwizard generated program? It seems to create a lot of assertion failures I'm not sure how to deal with.

Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 19 April 2004 at 8:37pm

Ok, I see it has to be not only in CMainFrame::LoadFrame but after the call to the parent class LoadFrame as well.

Are we supposed to manually create a .h file with a list of resource #defines for IDs? There is an import option in the designer but no export option.

Also I'm not sure where I am supposed to be hiding context menus for popups in the designer, do I put them as menus on the main menu bar and hide them with code later on, or should they just be their own toolbar?

Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 19 April 2004 at 8:56pm

... and a bug, I think:

If you use LoadDesignerBars, then afterwards GetCommandBars()->GetMenuBar()->SetFlags(x tpFlagAddMDISysPopup); the system menu will not have the icons for the restore/min/max/close options like they normally do when using command bars the other way.

BTW, is the ability to apply the command bars paint manager to the system menu for non-maximized MDI child windows going to happen or not?

Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 22 April 2004 at 12:11pm

Note for other forum readers, I got most of these problems solved via email.

If you add the code:
    UINT nIDMenuBarIcons[] = {SC_RESTORE, SC_MINIMIZE, SC_MAXIMIZE, SC_CLOSE};
    XTPImageManager()->SetIcons(XTP_IDB_MENUBAR_ICONS, nIDMenuBarIcons, 4, CSize(16, 16));
It will add the 4 icons back to the MDI menu properly.

The "import" button in designer really means "Export" -- you can have it create a .h file of #defines for you. The only proboblem I see is some overlap of defines already defined, so I just #include that .h right after resource.h with a few #undef's between the two in order to fix compiler warnings about things like ID_EDIT_COPY being redefined with the same value.

Also, for people wondering how to create popup context menus with the designer, you add them to your menu bar, then add the list of menu items to them in the designer, then remove the popup from the menu bar. The instance in the controls pane will remember all the items added.
In order to display the popup, you do something like:
    CXTPCommandBars *pCommandBars = static_cast<CXTPMDIFrameWnd *>(AfxGetMainWnd())->GetCommandBars();
    CXTPControlPopup *pControlPopup = reinterpret_cast<CXTPControlPopup *>(pCommandBars- >m_pDesignerControls->FindControl(IDR_POPUPMENUID));
    CXTPPopupBar *pPopupBar = reinterpret_cast<CXTPPopupBar *>(pControlPopup->GetCommandBar());
    CXTPCommandBars::TrackPopupMenu(pPopupBar, TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);

That is the hard part, since while documentation is only as helpful as crawling through the headers yourself, neither is going to tell you when its safe to upcast thigs such as those two reinterpret_cast's that are upcasting a CXTPControl to a CXTPControlPopup, or a CXTPCommandBar to a CXTPPopupBar.  I'm sure not every CXTPControl can be safely cast to a CXTPControlPopup, since CXTPControlPopup is derived from CXTPControl, but in this case I know its safe.

Thanks Oleg!

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: 22 April 2004 at 2:23pm
the better use MFC macros DYNAMIC_DOWNCAST(CXTPControlPopup, ..)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 22 April 2004 at 2:26pm
Does that help us figure out what is safe to cast to what? It seems like more bloat to MFC to be calling a lot of functions for simple things sometimes.
Plus those are both UPcasts not DOWNcasts, right?

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.172 seconds.