共用方式為


CToolBar::SetSizes

呼叫此成員函式將工具列的按鈕加入至大小,以像素為單位,指定在 sizeButton

void SetSizes(
   SIZE sizeButton,
   SIZE sizeImage 
);

參數

  • sizeButton
    在每個按鈕的大小 (以像素為單位)。

  • sizeImage
    在每個像素的影像大小。

備註

sizeImage 參數必須以像素為單位),在工具列的點陣圖的影像大小,包含。 在 sizeButton 的 大小必須足以對影像加 7 像素的額外寬度為 6 像素和額外的高度。 這個函式也會將高度相容的工具列按鈕。

呼叫此成員函式只能用於未遵循 Windows 軟體介面方針 設計建議的給按鈕和影像大小的工具列上的。

範例

// This code fragment is taken from CMainFrame::OnCreate
// CMainFrame is derived from CMDIFrameWnd

// This example shows how to add text to toolbar buttons.
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, _T("New")));
VERIFY(m_wndToolBar.SetButtonText(1, _T("Open")));
VERIFY(m_wndToolBar.SetButtonText(2, _T("Save")));
VERIFY(m_wndToolBar.SetButtonText(4, _T("Cut")));
VERIFY(m_wndToolBar.SetButtonText(5, _T("Copy")));
VERIFY(m_wndToolBar.SetButtonText(6, _T("Paste")));
VERIFY(m_wndToolBar.SetButtonText(8, _T("Print")));
VERIFY(m_wndToolBar.SetButtonText(9, _T("About")));

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

需求

Header: afxext.h

請參閱

參考

CToolBar 類別

階層架構圖

CToolBar::LoadBitmap

CToolBar::SetButtonInfo

CToolBar::SetButtons