LoadDesignerBars
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=638
Printed Date: 23 December 2024 at 7:11pm Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: LoadDesignerBars
Posted By: Ark42
Subject: LoadDesignerBars
Date 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.
|
Replies:
Posted By: Ark42
Date 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?
|
Posted By: Ark42
Date 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?
|
Posted By: Ark42
Date 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!
|
Posted By: Oleg
Date Posted: 22 April 2004 at 2:23pm
the better use MFC macros DYNAMIC_DOWNCAST(CXTPControlPopup, ..)
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: Ark42
Date 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?
|
|