#include <CommCtrl.h>
static HWND hRebar;
BOOL CreateRebar(HWND hWndOwner)
{
REBARINFO rbi;
REBARBANDINFO rbBand;
RECT rc;
HWND hwndCB, hwndTB, hwndRB;
DWORD dwBtnSize;
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_COOL_CLASSES|ICC_BAR_CLASSES;
InitCommonControlsEx(&icex);
DWORD dwStyle = RBS_FIXEDORDER|RBS_BANDBORDERS|RBS_DBLCLKTOGGLE|RBS_REGISTERDROP /
|RBS_VARHEIGHT|CCS_NODIVIDER|CCS_NOPARENTALIGN|WS_BORDER|WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_VISIBLE;
DWORD dwStyle1 = WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|
WS_CLIPCHILDREN|RBS_VARHEIGHT|
CCS_NODIVIDER;
hRebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, dwStyle1,
0, 0, 500, 20, hWndOwner, (HMENU)5000, hInst, NULL);//100改为1000将出现排列不同的现象
// Each band usually has a gripper at its left-hand edge. Grippers are used when two or
//more bands on a single strip exceed the width of the window. By dragging the gripper to the left or right,
//users can control how much space is allocated to each band.
//特别注意:Version 5.80 of the common controls provides a way to make tools that have been covered by another
//band accessible to the user. If you set the RBBS_USECHEVRON flag in the fStyle member of the band's REBARBANDINFO structure,
//a chevron will be displayed for toolbars that have been covered. 因此对RBBS_USECHEVRON出现的chevron按钮只是针对于toolbars控件
//其它控件将不能出现这样的功能;
for (int i=0; i<10; i++)
{
HWND hwndButton = CreateWindow(
_T("BUTTON"), // predefined class
_T("OK"), // button text
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
0, // starting x position
0, // starting y position
100, // button width
20, // button height
hRebar, // parent window
NULL, // No menu
hInst,
NULL
);
rbBand.cbSize = sizeof(REBARBANDINFO); // Required
rbBand.fMask = RBBIM_TEXT|RBBIM_CHILD|RBBIM_COLORS|RBBIM_BACKGROUND|RBBIM_STYLE|RBBIM_CHILDSIZE|RBBIM_SIZE;
rbBand.fStyle = RBBS_USECHEVRON|RBBS_CHILDEDGE | RBBS_FIXEDBMP;
rbBand.hbmBack = LoadBitmap(hInst,
MAKEINTRESOURCE(IDC_MYICON));
GetWindowRect(hwndButton, &rc);
rbBand.lpText = _T("Button");
rbBand.hwndChild = hwndButton;
rbBand.cxMinChild = 100;
rbBand.cyMinChild = 20;
SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);
}
return TRUE;
}