Large Button ToolBar Refresh Problem
Eric Marc Loebenberg -- loebenbe@qc.bell.ca Tuesday, October 01, 1996 Kaline, thank you very much, this definately solves part of the problem. However, the following problems are still there. a) if the toolbar is floating, the CFrameWnd::RecalcLayout has no effect and I still have to click in the floating toolbar to get it to recalculate. b) I have a dynamically placed combo box in the toolbar. When doing the RecalcLayout, the box remains where it was although all the buttons are now correctly displayed. When I click on the toolbar, the combo box is then redrawn in the correct spot. Do you have any ideas. Thanks a lot! ---------- > From: Kaline den UIjl> To: Eric Marc Loebenberg > Subject: Re: Large Button ToolBar Refresh Problem > Date: Tuesday, October 01, 1996 3:32 AM > > Eric Marc Loebenberg wrote: > > > > Environment: MSVC 4.2, Windows 95 > > > > I have two sets of toolbar buttons, small and large. > > When I switch from small to large, the large are runcated to the height of > > the small toolbar. > > When I switch from large to samll, the toolbar height remains large and > > the small buttons are displayed. > > > > - I am using .... > > SetSizes(sizeButton, sizeImage); > > SetHeight(sizeButton.cy+10); > > LoadBitmap(nToolBar); > > Invalidate(); > > > > - When I click anywhere on the toolbar, it then correctly displays the > > toolbar > > height > > > > Can anyone tell me what I have to do to get the toolbar properly refreshed > > after loading > > the smaller or larger bitmap? > > > > *************************************************************** > > Eric Marc Loebenberg loebenbe@qc.bell.ca > > Bell Sygma Inc. > > 700 de la Gauchetiere West Tel: 514-870-0465 > > Room 14W1 Fax: 514-870-7583 > > Montreal, Quebec, Canada > > H3B 4L1 > > > > *************************************************************** > > Eric Marc Loebenberg loebenbe@qc.bell.ca > > Bell Sygma Inc. > > 700 de la Gauchetiere West Tel: 514-870-0465 > > Room 14W1 Fax: 514-870-7583 > > Montreal, Quebec, Canada > > H3B 4L1 > > Hello, > > You need to do a RecalcLayout(TRUE). The SetHeight() and Invalidate() > are not neccessary. > > Kaline den Uijl
Jim Alsup -- epi!alsup@amd.com Wednesday, October 02, 1996 I avoided these problems in my app by creating both a big toolbar and a small toolbar. I then always kept one or the other toolbar hidden. This maybe wasn't the most efficent method, but it was pretty simple, and had a positive (for us) side effect of allow different positioning for small vrs large toolbars. -jim alsup ja@episupport.com On 1 Oct 96 at 8:58, Eric Marc Loebenberg wrote about "Re: Large Button ToolBar Refresh Pr": > From: "Eric Marc Loebenberg"> To: "Kaline den UIjl" > Cc: "MFC" > Subject: Re: Large Button ToolBar Refresh Problem > Date: Tue, 1 Oct 1996 08:58:11 -0400 > Reply-to: mfc-l@netcom.com > Kaline, thank you very much, this definately solves part of the problem. > However, the following problems are still there. > > a) if the toolbar is floating, the CFrameWnd::RecalcLayout has no effect > and I still have to click in the floating toolbar to get it to > recalculate. > > b) I have a dynamically placed combo box in the toolbar. When doing the > RecalcLayout, the box remains where it was although all the buttons are > now correctly displayed. When I click on the toolbar, the combo box is > then redrawn in the correct spot. > > Do you have any ideas. Thanks a lot! > ---------- > > From: Kaline den UIjl > > To: Eric Marc Loebenberg > > Subject: Re: Large Button ToolBar Refresh Problem > > Date: Tuesday, October 01, 1996 3:32 AM > > > > Eric Marc Loebenberg wrote: > > > > > > Environment: MSVC 4.2, Windows 95 > > > > > > I have two sets of toolbar buttons, small and large. > > > When I switch from small to large, the large are runcated to the > height of > > > the small toolbar. > > > When I switch from large to samll, the toolbar height remains large > and > > > the small buttons are displayed. > > > > > > - I am using .... > > > SetSizes(sizeButton, sizeImage); > > > SetHeight(sizeButton.cy+10); > > > LoadBitmap(nToolBar); > > > Invalidate(); > > > > > > - When I click anywhere on the toolbar, it then correctly displays the > > > toolbar > > > height > > > > > > Can anyone tell me what I have to do to get the toolbar properly > refreshed > > > after loading > > > the smaller or larger bitmap? > > > > > > *************************************************************** > > > Eric Marc Loebenberg loebenbe@qc.bell.ca > > > Bell Sygma Inc. > > > 700 de la Gauchetiere West Tel: 514-870-0465 > > > Room 14W1 Fax: 514-870-7583 > > > Montreal, Quebec, Canada > > > H3B 4L1 > > > > > > *************************************************************** > > > Eric Marc Loebenberg loebenbe@qc.bell.ca > > > Bell Sygma Inc. > > > 700 de la Gauchetiere West Tel: 514-870-0465 > > > Room 14W1 Fax: 514-870-7583 > > > Montreal, Quebec, Canada > > > H3B 4L1 > > > > Hello, > > > > You need to do a RecalcLayout(TRUE). The SetHeight() and Invalidate() > > are not neccessary. > > > > Kaline den Uijl > >
Roger Onslow/Newcastle/Computer Systems Australia/ Saturday, October 05, 1996 I use the following code for Large/Small buttons in a CToolbar-derive class LoadToolBar (); // loads the appropriate toolbar (large/small) CFrameWnd* pParentFrame = GetDockingFrame (); if (pParentFrame) pParentFrame->RecalcLayout (); This works fine for me ! Roger
Eric Marc Loebenberg -- loebenbe@qc.bell.ca Sunday, October 06, 1996 Thanks to those who responded to this problem. First, here is a copy of the original problem: > > Environment: MSVC 4.2, Windows 95 > > I have two sets of toolbar buttons, small and large. > When I switch from small to large, the large are truncated to the height of > the small toolbar. > When I switch from large to small, the toolbar height remains large and > the small buttons are displayed. > > - I am using .... > SetSizes(sizeButton, sizeImage); > SetHeight(sizeButton.cy+10); > LoadBitmap(nToolBar); > Invalidate(); > > - When I click anywhere on the toolbar, it then correctly displays the > toolbar > height > > Can anyone tell me what I have to do to get the toolbar properly refreshed > after loading > the smaller or larger bitmap? After some trial and error experimentation, I came up with a working solution. Firstly I create my toolbar on the heap rather a member of the frame window. This allows me to easily delete it and recreate with appropriate constructors/destructors. If the toolbar is not floating, the solution is very simple: You use CToolBar::SetSizes() and CToolBar::LoadBitMap(), then CFrameWnd::RecalcLayout(); If the toolbar is floating, you have to destroy it (Thanks James), and recreate it. Before doing so, it is a good idea to save the style and position. I used something like this within my frame window: // only if changed button size and toolbar is floating if ((bLargeButtons != ToolDlg.m_bLarge) && m_ToolBar->IsFloating()) { CRect rect; // floating toolbar's rectangle CPoint point; // floating toolbar's top left point DWORD style; // floating toolbar's toolbar style m_ToolBar->GetWindowRect(&rect); point.x = rect.left; point.y = rect.top; style = m_ToolBar->GetBarStyle(); m_ToolBar->DestroyWindow(); delete m_ToolBar; CreateToolBar(); FloatControlBar(m_ToolBar,point,style); m_ToolBar->SetBox(); // sets the combo box or edit box } else { // change bitmap and toolbar button size m_ToolBar->SetColorAndSize(ToolDlg.m_bColor,ToolDlg.m_bLarge); RecalcLayout(TRUE); } -- *************************************************************** Eric Marc Loebenberg loebenbe@qc.bell.ca Bell Sygma Inc. 700 de la Gauchetiere West Tel: 514-870-0465 Room 14W1 Fax: 514-870-7583 Montreal, Quebec, Canada H3B 4L1
Jim Barry -- Jim.Barry@ilp.com Wednesday, October 09, 1996 Environment: MSVC 4.1, Windows 95 Here's my distillation of how to swap between small and large toolbar buttons: BOOL CMainFrame::SetToolBarSize(BOOL fBigButtons) { if (!m_wndToolBar.LoadToolBar( fBigButtons ? IDR_MAINFRAME_LARGE : IDR_MAINFRAME)) { TRACE0("Failed to load toolbar\n"); return FALSE; // fail } m_wndToolBar.GetDockingFrame()->RecalcLayout(); m_fBigButtons = fBigButtons; return TRUE; } This works admirably for such a small amount of code. The only trouble is that I would like to preserve the number of rows in the toolbar (if floating) when the button size changes. At the moment, if I swap between the two sizes, the toolbar gets thinner and thinner until it is a single column. I tried using CToolBarCtrl::GetRows and CToolBarCtrl::SetRows, but it looks like GetRows returns incorrect values and SetRows totally ignores the requested row count! Any ideas? - Jim
| Вернуться в корень Архива |