Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

CToolBar::SetSizes 

Call this member function to set the toolbar's buttons to the size, in pixels, specified in sizeButton.


void SetSizes(
   SIZE sizeButton,
   SIZE sizeImage 
);

Parameters

sizeButton

The size in pixels of each button.

sizeImage

The size in pixels of each image.

The sizeImage parameter must contain the size, in pixels, of the images in the toolbar's bitmap. The dimensions in sizeButton must be sufficient to hold the image plus 7 pixels extra in width and 6 pixels extra in height. This function also sets the toolbar height to fit the buttons.

Call this member function only for toolbars that do not follow Windows Interface Guidelines for Software Design recommendations for button and image sizes.

// This example shows how to add text to toolbar buttons.
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
      return -1;

   //Create a toolbar. Resource ID of the toolbar to be loaded 
   //is IDR_MAINFRAME.

   if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE 
      | CBRS_TOP) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
   {
      TRACE0("Failed to create toolbar\n");
      return -1;  // fail to create
   }
   
   //Show text on toolbar buttons.
   VERIFY(m_wndToolBar.SetButtonText(0,"New"));
   VERIFY(m_wndToolBar.SetButtonText(1,"Open"));
   VERIFY(m_wndToolBar.SetButtonText(2,"Save"));
   VERIFY(m_wndToolBar.SetButtonText(4,"Cut"));
   VERIFY(m_wndToolBar.SetButtonText(5,"Copy"));
   VERIFY(m_wndToolBar.SetButtonText(6,"Paste"));
   VERIFY(m_wndToolBar.SetButtonText(8,"Print"));
   VERIFY(m_wndToolBar.SetButtonText(9,"About"));

   CRect temp;
   m_wndToolBar.GetItemRect(0,&temp);
   m_wndToolBar.SetSizes(CSize(temp.Width(),
      temp.Height()),CSize(16,15));

   return 0;
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.