How to load new toolbar at runtime from CView?
ARTO HAKOLA -- arto.hakola@sni.fi
Thursday, July 25, 1996
** High Priority **
Enviroment: Windows NT 3.51SP4, Visual C++ 4.1 & MSDN
How can I load new toolbar to CFrame at runtime?
I have following class structure:
CApp
CFrame
CView
CPropertySheet
CPropertyPage <--- from here I want to replace toolbar at runtime
I have tried following:
BOOL CXXXPage::OnSetActive()
{
CWnd *m_pCWnd = AfxGetApp()->m_pMainWnd;
CToolBar *m_pOldToolBar = (CToolBar*)
m_pCWnd->GetDescendantWindow(AFX_IDW_TOOLBAR, TRUE);
m_pOldToolBar->LoadToolBar(IDR_NEWTOOLBAR);
}
This doesn't work...any good suggestions!?
regards,
Arto Hakola
Siemens Nixdorf Informationsystems
Finland
email: arto.hakola@sni.fi
http://www.sni.fi
Don.Irvine@net-tel.co.uk
Monday, July 29, 1996
[Mini-digest: 2 responses]
> ** High Priority **
I could say something facious to this, but I won't :-)
[Moderator's note: And I could say something facetious to this, but... ;-]
> How can I load new toolbar to CFrame at runtime?
>
> I have following class structure:
> CApp
> CFrame
> CView
> CPropertySheet
> CPropertyPage <--- from here I want to replace toolbar at runtime
>
> I have tried following:
> BOOL CXXXPage::OnSetActive()
> {
> CWnd *m_pCWnd = AfxGetApp()->m_pMainWnd;
> CToolBar *m_pOldToolBar = (CToolBar*)
> m_pCWnd->GetDescendantWindow(AFX_IDW_TOOLBAR, TRUE);
> m_pOldToolBar->LoadToolBar(IDR_NEWTOOLBAR);
> }
>
> This doesn't work...any good suggestions!?
Looks like it should work. What does it do/not do ?
Have you stepped into the code to see what is happening ?
You might want to try Invalidating the toolbar after LoadToolBar - don't
think this will make any difference though.
A better way of getting the toolbar is to use the GetControlBar function:
CFrameWnd* pFrameWnd = (CFrameWnd*) AfxGetMainWnd();
ASSERT_KINDOF(CFrameWnd, pFrameWnd);
CToolBar* pBar = (CToolBar*) pFrameWnd->GetControlBar(AFX_IDW_TOOLBAR);
ASSERT_KINDOF(CToolBar, pBar);
pBar->LoadToolBar(IDR_NEWTOOLBAR);
Don
-----From: ARTO HAKOLA
Hi!
I have tried following as you told:
"CFrameWnd* pFrameWnd = (CFrameWnd*) AfxGetMainWnd();
ASSERT_KINDOF(CFrameWnd, pFrameWnd);
CToolBar* pBar = (CToolBar*)
pFrameWnd->GetControlBar(AFX_IDW_TOOLBAR);
ASSERT_KINDOF(CToolBar, pBar);
pBar->LoadToolBar(IDR_NEWTOOLBAR);"
The result is, that it seems like new toolbar gets loaded but it won't
update bitmap images on the bar as it should.
Does anybody have any other tips to solve this problem?
Looks like it should work. What does it do/not do ?
Have you stepped into the code to see what is happening ?
You might want to try Invalidating the toolbar after LoadToolBar - don't
think this will make any difference though.
Roger Onslow -- Roger_Onslow@compsys.com.au
Friday, August 02, 1996
[snip]
>-----From: ARTO HAKOLA
>
>Hi!
>I have tried following as you told:
>
>"CFrameWnd* pFrameWnd = (CFrameWnd*) AfxGetMainWnd();
>ASSERT_KINDOF(CFrameWnd, pFrameWnd);
>CToolBar* pBar = (CToolBar*)
>pFrameWnd->GetControlBar(AFX_IDW_TOOLBAR);
>ASSERT_KINDOF(CToolBar, pBar);
>pBar->LoadToolBar(IDR_NEWTOOLBAR);"
>
>The result is, that it seems like new toolbar gets loaded but it won't
>update bitmap images on the bar as it should.
>Does anybody have any other tips to solve this problem?
Could this be due to the (infamous) Internet Explorer 3.0 Beta 2 bug which
affects the painting of toolbars?
Apparently (to repeat the story ad-nausium), the latest Beta of IE and/or
Mail&News add on installs a "faulty" COMDLG32.DLL and/or COMCTL32.DLL
(depending on who you talk to :-). This .DLL has the side effect of upsetting
the painting of tool bars (especially those in MFC apps). Don't know if this
is your problem, but if so then it may not be your fault (isn't it nice to be
able to blame MS!!)
Roger Onslow
RogerO@compsys.com.au
S.A.C. Madrid -- sacmad2@ibm.net
Tuesday, August 13, 1996
>** High Priority **
>
>Enviroment: Windows NT 3.51SP4, Visual C++ 4.1 & MSDN
>
>How can I load new toolbar to CFrame at runtime?
>
>I have following class structure:
>CApp
> CFrame
> CView
> CPropertySheet
> CPropertyPage <--- from here I want to replace toolbar at runtime
>
>I have tried following:
>BOOL CXXXPage::OnSetActive()
>{
> CWnd *m_pCWnd = AfxGetApp()->m_pMainWnd;
> CToolBar *m_pOldToolBar = (CToolBar*)
>m_pCWnd->GetDescendantWindow(AFX_IDW_TOOLBAR, TRUE);
> m_pOldToolBar->LoadToolBar(IDR_NEWTOOLBAR);
>}
>
>This doesn't work...any good suggestions!?
>
>regards,
>Arto Hakola
>Siemens Nixdorf Informationsystems
>Finland
>email: arto.hakola@sni.fi
>http://www.sni.fi
>
>
>
>
Look MFC general example DOCKTOOL. Perhaps you'll find help.
petter.hesselberg -- petter.hesselberg@ac.com
Thursday, August 15, 1996
Why load a new toolbar? How about loading a number
of toolbars to begin with, as in a multi-toolbar app, and
hiding/showing them as appropriate? Should be simpler.
If you really want to find out what's happening in your code,
try tracing into LoadToolbar and see what it does...
Regards,
Petter
| Вернуться в корень Архива
|