REBARINFO rbi;
REBARBANDINFO rbBand;
//初始化
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_COOL_CLASSES|ICC_BAR_CLASSES;
InitCommonControlsEx(&icex);
//创建Rebar
hWndRB = CreateWindowEx(WS_EX_TOOLWINDOW,REBARCLASSNAME, NULL,
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|
WS_CLIPCHILDREN|WS_BORDER|RBS_VARHEIGHT|
RBS_DBLCLKTOGGLE|RBS_BANDBORDERS|
CCS_NODIVIDER|CCS_NOPARENTALIGN,
0,0,rc.right,0,
hWndParent,
(HMENU)IDC_MAIN_REBAR,
hInst,
NULL);
//设置REBARINFO
rbi.cbSize = sizeof(REBARINFO); // Required when using this
// structure.
rbi.fMask = 0;
rbi.himl = (HIMAGELIST)NULL;
if(!SendMessage(hWndRB, RB_SETBARINFO, 0, (LPARAM)&rbi))
return NULL;
//创建工具栏或者菜单栏,或者其它控件窗口.
hWndMB = CreateMenuBar(hWndRB);
//设置REBARBANDINFO
dwBtnSize =(DWORD) SendMessage(hWndMB, TB_GETBUTTONSIZE, 0,0);
rbBand.cbSize = sizeof(rbBand);
rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE |
RBBIM_SIZE;
rbBand.fStyle = RBBS_CHILDEDGE;
rbBand.hwndChild =hWndMB;
rbBand.cx =0;
rbBand.cxMinChild = 0;
rbBand.cyMinChild = HIWORD(dwBtnSize);
//插入BAND
SendMessage(hWndRB, RB_INSERTBAND, (WPARAM)0, (LPARAM)&rbBand);
程序运行如下:
本文引用通告地址: http://blog.csdn.net/ruchimy/services/trackbacks/364236.aspx