Re: Changing toolbar captions
On Jun 3, 10:43 am, "David Webber" <d...@musical-dot-demon-dot-co.uk>
"Ajay" <ajayka...@yahoo.com> wrote in message
I am getting frustrated trying to change my toolbar captions (when th=
decides he wants to see them in a different language)....
I dont exactly recall what I did but its not going to work the way you
are doing it. I remember doing GetParentFrame or something like that
(to get to CMiniDockFrame ??) and then changing the title. Run Spy++
to see the layout and then change the text of the parent. IIRC,
floating introduces another frame or something on those lines.<
Thanks Ajay. Brilliant!
The class is CMiniFrameWnd - one I hadn't come across before. You'=
on: one of these is put round the toolbar when it is floated. Spy+=
me it, and after I have changed the CToolBar's caption, I can see the gre=
area in the midddle is a window with the new caption, and what looks like
the frame is another window with the old caption!
More details are hard to find in the documentation. However
CControlBar::GetDockingFrame() is documented as returning a pointer to th=
frame around a floating toolbar, so bingo! the following code does it=
CToolBar pWndToolBar = ...
pWndToolBar->SetWindowText( sCaption );
// Now if this is floating, it has an associated
// CMiniFrameWnd which has the caption bar. We
// need to change its text too.
// CControlBar::GetDockingFrame() is documented as
// giving the CMiniFrameWnd as long as the toolbar
// is floating. And so:
if( pWndToolBar->IsFloating() )
CFrameWnd *pWndFrame = pWndToolBar->GetDockingFrame();
if( pWndFrame ) pWndFrame->SetWindowText( sCaption );
Simple when you know how!
It took me a long while to understand the whole toolbar/control bar
architecture. I thinks its one of the worst designs in MFC. I did
indicate it to MSFT/VC program manager as well when I was there in 2001
(?). However after having gone thru the design, I felt very
comfortable with it.
I feel guilty that I havent used MFC in a long time.