15,979
社区成员
发帖
与我相关
我的任务
分享
当不存在ttbutton的时候, 采用的是 setbuttonsytel的法子,
当不存在ttbutton的时候, 采用的是 setbuttonsytel的法子,
当不存在ttbutton的时候, 采用的是 setbuttonsytel的法子,
参考:
http://msdn.microsoft.com/en-US/library/w13yte29(v=vs.80).aspx
A button's style determines how the button appears and how it responds to user input.
Before calling SetButtonStyle, call the GetButtonStyle member function to retrieve the button or separator style.
所以有代码:
BOOL CMainFrame::CreatePaletteBar()
{
if (!m_wndPaletteBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_SIZE_DYNAMIC |
CBRS_TOP | CBRS_TOOLTIPS, ID_PALETTEBAR) ||
!m_wndPaletteBar.LoadBitmap(IDB_PALETTE) ||
!m_wndPaletteBar.SetButtons(palette,
sizeof(palette)/sizeof(UINT)))
{
TRACE0("Failed to create toolbar\n");
return FALSE; // fail to create
}
m_wndPaletteBar.SetWindowText(_T("Palette"));
m_wndPaletteBar.EnableDocking(0);
// Create the Palette. We are using hardcoded numbers for ease here
// normally the location would be read in from an ini file.
CPoint pt(GetSystemMetrics(SM_CXSCREEN) - 100,
GetSystemMetrics(SM_CYSCREEN) / 3);
//m_wndPaletteBar.SetColumns(3);
FloatControlBar(&m_wndPaletteBar, pt);
UINT dwStyle=m_wndPaletteBar.GetButtonStyle(2);
dwStyle|=TBBS_SEPARATOR;
m_wndPaletteBar.SetButtonStyle(2,dwStyle);
return TRUE;
}
UINT dwStyle=m_wndPaletteBar.GetButtonStyle(2);
dwStyle|=TBBS_SEPARATOR;
m_wndPaletteBar.SetButtonStyle(2,dwStyle);
}
palette id数组的定义为:
static UINT BASED_CODE palette[] =
{
// same order as in the bitmap 'palette.bmp'
ID_PALETTEERASE,
ID_PALETTEPEN,
ID_SEPARATOR, //已经改成第2个位置了
ID_PALETTESELECT,
ID_PALETTEBRUSH,
ID_PALETTESPRAY,
ID_PALETTEPAINT,
ID_PALETTELINE,
ID_PALETTEEYEDROP,
ID_PALETTEMAG,
ID_PALETTERECT,
ID_PALETTEROUND,
ID_PALETTEOVAL
};
把id数组的第2个设置值为:ID_SEPARATOR的原因:
参考:
http://msdn.microsoft.com/en-US/library/xeh4y0x1(v=vs.80).aspx
If an element of the array has the value ID_SEPARATOR, a separator is created in the corresponding position of the toolbar. This function also sets each button's style to TBBS_BUTTON and each separator's style to TBBS_SEPARATOR, and assigns an image index to each button. The image index specifies the position of the button's image within the bitmap.
源码在20楼