|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Chris Anderson
|
Apr 10, 2007 - 6:04 PM
|
hi all,
I ran into an issue when integrating prof-ui 264 into a legacy MFC app, even though we figured out a solution, it seems more like a work around, and I would like to see whether it will be addressed inside prof-ui in the future.
In the legacy code, we will create a few toolbars inside CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) function, here is the code excerpt
class CMainFrame : public CMDIFrame { CToolBar m_wndToolBar1; ... }
// create toolbar 1 if (!m_wndToolBar1.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP, IDR_TOOLBAR1) || !m_wndToolBar.LoadToolBar(IDR_TOOLBAR1)) { TRACE0("Failed to create toolbar1\n"); return -1; // fail to create }
// create toolbar 2 ...
Later we need a reference to the toolbar
CControlBar* pBar = m_pToolbarFrame->GetControlBar(IDR_TOOLBAR1);
After the integration, it would look like this
class CMainFrame : public CExtNCW <CMDIFrameWnd> { CExtToolControlBar m_wndToolBar1; ... }
if ( !m_wndScrollToolBar.Create( _T( "ToolBar1" ), this,AFX_IDW_TOOLBAR) || !m_wndScrollToolBar.LoadToolBar( IDR_TOOLBAR1)) {
}
The problem : now I’m not able to get the reference to toolbar1 with this call
CControlBar* pBar = m_pToolbarFrame->GetControlBar(IDR_TOOLBAR1);
Even though it’s possible to hard coded and return a pointer of CExtToolControlBar, but the CControlBar pointer is used a lot, and I don’t want to change that.
After some debugging, it turns out that CExtToolControlBar::Create() doesn’t add itself to it’s parent’s control list. to make sure CFrameWnd::GetControlBar() still works with CExtToolControlBar, I have to manually add it to CFrameWnd’s m_listControls
_AfxSetDlgCtrlID(m_wndToolBar1.m_hWnd, IDR_TOOLBAR1); this->AddControlBar(&m_wndToolBar1);
Shoud these be done in CExtControlBar::Create( ) to maintain the compatibility with CFrameWnd::GetControlBar() ?
thanks
|
|
Technical Support
|
Apr 11, 2007 - 10:33 AM
|
CExtControlBar and all classes derived from it (including CExtToolControlBar and CExtMenuControlBar ) are added to the CFrameWnd::m_listControlBars list of CControlBar* pointers only if they are enabled for docking. We would like not to change this specific issue in Prof-UIS and ask you to add the pointer to the toolbar manually.
|
|