REBAR API的创建

 #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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值