You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Win32应用多行Rebar独立Band高度设置问题求助

Win32 Rebar多行高度不一致问题

我要在Win32应用里实现一个两行的Rebar,每行高度不同:第一行包含2个Band,第二行包含1个Band。最初尝试创建两个Rebar不可行,正确方式是使用单个Rebar,让部分Band占满窗口宽度。我设置Band #1和Band #3占满宽度后成功实现多行布局,Rebar也能适配Band #2工具栏的大按钮。但独占一行的Band #3与前两个Band高度相同,不符合需求——它应根据内部小文本框设置更小高度。我为Rebar添加RBBS_VARIABLEHEIGHT样式,调整Band #3的cyChild和cyMinChild属性均无效,已知该需求可实现,以下是我的代码:

hWndRebar = CreateWindowEx(0, REBARCLASSNAME, NULL, WS_VISIBLE | WS_BORDER | WS_CHILD | RBS_BANDBORDERS | RBBS_VARIABLEHEIGHT,
    0, 0, 0, 0, hWndParent, NULL, GetModuleHandle(NULL), NULL);

REBARINFO      rbi;
REBARBANDINFO  rbbi = { sizeof(REBARBANDINFO_V3_SIZE) };

// Add Band #1 - combobox
// COMBOBOX CREATION CODE OMITTED...
ZeroMemory(&rbbi, sizeof(rbbi));
rbbi.cbSize = REBARBANDINFO_V3_SIZE;
rbbi.fMask = RBBIM_SIZE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_ID | RBBIM_STYLE | RBBIM_TEXT;
rbbi.cxMinChild = rcComboBox.right - rcComboBox.left;
rbbi.cyMinChild = rcComboBox.bottom - rcComboBox.top;
rbbi.cx = 0;
rbbi.fStyle = RBBS_CHILDEDGE |
    RBBS_FIXEDBMP |
    RBBS_GRIPPERALWAYS;
rbbi.hwndChild = hWndSelectorComboBox;
SendMessage(hWndRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)(LPREBARBANDINFO)&rbbi);

// Add Band #2 - Toolbar
// TOOLBAR CREATION CODE OMITTED...
// Get toolbar dimensions of RBBand
DWORD dwBtnSize = (DWORD)SendMessage(hWndToolbarCutCopyPaste, TB_GETBUTTONSIZE, 0, 0);

ZeroMemory(&rbbi, sizeof(rbbi));
rbbi.cbSize = REBARBANDINFO_V3_SIZE;
rbbi.fMask = RBBIM_SIZE |
    RBBIM_CHILD |
    RBBIM_CHILDSIZE |
    RBBIM_ID |
    RBBIM_STYLE |
    RBBIM_TEXT |
    RBBIM_BACKGROUND;
rbbi.fStyle = RBBS_CHILDEDGE |
    RBBS_GRIPPERALWAYS;
// Set values unique to the band with the toolbar.
rbbi.hwndChild = hWndToolbarCutCopyPaste;
rbbi.cyChild = HIWORD(dwBtnSize);
rbbi.cxMinChild = 3 * LOWORD(dwBtnSize);
rbbi.cyMinChild = HIWORD(dwBtnSize);
// The default width is the width of the buttons.
rbbi.cx = 0;

SendMessage(hWndRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)(LPREBARBANDINFO)&rbbi);

// Add Band #3 - Full-size textbox
ZeroMemory(&rbbi, sizeof(rbbi));
rbbi.cbSize = REBARBANDINFO_V3_SIZE;
rbbi.fMask = RBBIM_SIZE |
    RBBIM_CHILD |
    RBBIM_CHILDSIZE |
    RBBIM_ID |
    RBBIM_STYLE |
    RBBIM_TEXT |
    RBBIM_BACKGROUND;
rbbi.cxMinChild = rcFindValueEdit.right - rcFindValueEdit.left;
rbbi.cyMinChild = 20; // TRIED THIS: custom small cyMinChild value
rbbi.cx = 100;
rbbi.cyChild = 30; // TRIED THIS: Shouldn't be ignored with RBBS_VARIABLEHEIGHT
rbbi.fStyle = RBBS_CHILDEDGE |
    RBBS_FIXEDBMP |
    RBBS_GRIPPERALWAYS |
    0;
rbbi.hwndChild = hWndFindValueEdit;

SendMessage(hWndRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)(LPREBARBANDINFO)&rbbi);
// ALSO TRIED THIS: Force a SetBandInfo message
SendMessage(hWndRebar, RB_SETBANDINFO, (WPARAM)2/*3rd*/, (LPARAM)(LPREBARBANDINFO)&rbbi);

内容的提问来源于stack exchange,提问作者gene b.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 08:40:18