LoadDesignerBars |
Post Reply |
Author | |
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
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. |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
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? |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
... 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? |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
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! |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
the better use MFC macros DYNAMIC_DOWNCAST(CXTPControlPopup, ..)
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Ark42
Senior Member Joined: 20 October 2003 Status: Offline Points: 291 |
Post Options
Thanks(0)
|
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? |
|
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 |