Inserting & Deleting with CToolBar
Anthony Whitford -- whitford%mspo3@mprgate.mpr.ca
Wednesday, March 27, 1996
Environment: NT 4.0 beta, MSVC++ 4.1
I have an application with a toolbar (CToolBar). When a feature is
activated, some buttons are added to the toolbar. When the feature ends,
the previously added buttons are removed. I use CToolBar::GetToolBarCtrl
to get the CToolBarCtrl instance, then call InsertButton and
DeleteButton.
The buttons are added and removed fine. My problem is that the toolbar
is not being properly painted after deleting the buttons--you must touch
the toolbar with the mouse or move the window around to get a proper
repaint. Also, the toolbar had the focus when I start deleting the
buttons--this might be important.
You may be thinking, "Just call Invalidate or UpdateWindow."
Unfortunately, I have tried both and neither works. In fact, the code
is similar to the following:
...
DeleteButton stuff
...
GetFrameWnd()->GetToolBar().GetToolBarCtrl().AutoSize();
GetFrameWnd()->RecalcLayout(FALSE);
GetFrameWnd()->GetToolBar().Invalidate();
...
The invalidate seems to have no effect. I question if the AutoSize call
is really doing anything too. I know the RecalcLayout is important
because otherwise the toolbar size does not get updated.
What am I missing? Or is this a problem with the common control?
Thanks,
Anthony
(whitford@mpr.ca)
Jeremy Smith -- jeremy_smith@ccmail-gw.mentec.ie
Monday, April 01, 1996
I have had problems with the CToolBar. You don't say exactly how it
doesn't get repainted. I ended up doing several things:
Calling AfxGetApp()->OnIdle(-1) is a good idea to make sure the
buttons are immediately updated.
Invalidate() the parent window(s) of the CToolBar (especially on
dockable bars which are floating) being careful not to end up
re-painting the Frame.
The window hierarchy of a CToolBar see,s remarkably complex to me
Jeremy
(jeremy.Smith@mentec.ie)
______________________________ Reply Separator _________________________________
Subject: Inserting & Deleting with CToolBar
Author: mfc-l@netcom.com at internet-mail
Date: 31/03/96 01:40
Environment: NT 4.0 beta, MSVC++ 4.1
I have an application with a toolbar (CToolBar). When a feature is
activated, some buttons are added to the toolbar. When the feature ends,
the previously added buttons are removed. I use CToolBar::GetToolBarCtrl
to get the CToolBarCtrl instance, then call InsertButton and
DeleteButton.
The buttons are added and removed fine. My problem is that the toolbar
is not being properly painted after deleting the buttons--you must touch
the toolbar with the mouse or move the window around to get a proper
repaint. Also, the toolbar had the focus when I start deleting the
buttons--this might be important.
You may be thinking, "Just call Invalidate or UpdateWindow."
Unfortunately, I have tried both and neither works. In fact, the code
is similar to the following:
...
DeleteButton stuff
...
GetFrameWnd()->GetToolBar().GetToolBarCtrl().AutoSize();
GetFrameWnd()->RecalcLayout(FALSE);
GetFrameWnd()->GetToolBar().Invalidate();
...
The invalidate seems to have no effect. I question if the AutoSize call
is really doing anything too. I know the RecalcLayout is important
because otherwise the toolbar size does not get updated.
What am I missing? Or is this a problem with the common control?
Thanks,
Anthony
(whitford@mpr.ca)
| Вернуться в корень Архива
|