From: david on
Hi,

I used the following code to insert a combo box into my rebar control.

hwndBtn = CreateWindowEx(0,
_T("COMBOBOX"), _T("TEST"),
WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST ,
0, 0, 10,
100, // the
height of the combo box is 10px;
hwndRB, (HMENU)ID_MYBUTTON, hInst, NULL);

rbBand.lpText = _T("COMBOBOX");
rbBand.cch = 10;
rbBand.hwndChild = hwndBtn;
rbBand.cxMinChild = 0;
rbBand.cyMinChild = 30;
// i set
the minimum height of the rebar band to 30px
rbBand.cyMaxChild = 100;
rbBand.cxIdeal = rbBand.cx = 10;
rbBand.wID = ID_MYBUTTON;
//rbBand.cx = 100;
//rbBand.cyChild = 100;

lr = SendMessage(hwndRB, RB_INSERTBAND, (WPARAM)-1,
(LPARAM)&rbBand);

When I click the drop-down list button, the list is displayed as a
line...But, to my amusement, if I set the REBARBANDINFO::cyMinChild to
a smaller value, say 10, the list can be displayed completely.

Any idea about this? Thanks
From: Christian ASTOR on
david wrote:

> When I click the drop-down list button, the list is displayed as a
> line...But, to my amusement, if I set the REBARBANDINFO::cyMinChild to
> a smaller value, say 10, the list can be displayed completely.
>
> Any idea about this? Thanks

If there are no items, the default Combo Box Listbox (ComboLBox) height
is resized to the band height when the band is inserted.
If cyMinChild is too small, it's not resized.
From: David Shen on
Christian ASTOR wrote:
> david wrote:
>
>> When I click the drop-down list button, the list is displayed as a
>> line...But, to my amusement, if I set the REBARBANDINFO::cyMinChild to
>> a smaller value, say 10, the list can be displayed completely.
>>
>> Any idea about this? Thanks
>
> If there are no items, the default Combo Box Listbox (ComboLBox) height
> is resized to the band height when the band is inserted.
> If cyMinChild is too small, it's not resized.

I am not using a Combo Box Listbox, I am using a Combo Box Drop-down
box. And I have some test strings inserted into the Combo Box.

To my observation,
- if the cyMinChild value is too small, the drop-drop down list can be
displayed completely, but the combo box cannot be rendered beautifully
in the band.
- if the cyMinChild value is a greater one, but is not greater enough
to display all the items in the drop-down list, the drop-down list is
displayed as a line.
- if the cyMinChild is greater enough that all the items in the
drop-down list can be displayed completely, everything is fine, except
you got a huge band.

Following is my code-snippet:

// create rebar
hwndRB = CreateWindowEx(WS_EX_TOOLWINDOW,
REBARCLASSNAME, _T(""),
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
RBS_BANDBORDERS | RBS_VERTICALGRIPPER ,
0,0, 0, 0,
hWnd,NULL, hInst, NULL);

// init rebar
rbi.cbSize = sizeof(REBARINFO);
rbi.fMask = 0;
rbi.himl = (HIMAGELIST)NULL;
lr = SendMessage(hwndRB, RB_SETBARINFO, 0, (LPARAM)&rbi);

rbBand.cbSize = sizeof(REBARBANDINFO);
rbBand.fMask = RBBIM_TEXT | RBBIM_STYLE | RBBIM_CHILDSIZE |
RBBIM_CHILD | RBBIM_ID | RBBIM_SIZE ;
rbBand.fStyle = RBBS_CHILDEDGE;

// insert a band
hwndBtn = CreateWindowEx(0,
_T("COMBOBOX"), _T("TEST"),
WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST ,
0, 0, 10, 70,
hwndRB, (HMENU)ID_MYBUTTON, hInst, NULL);

rbBand.lpText = _T("COMBOBOX");
rbBand.cch = 10;
rbBand.hwndChild = hwndBtn;
rbBand.cxMinChild = 0;
rbBand.cyMinChild = 10; // in my case, if it's <25,
rbBand.cyMaxChild = 50;
rbBand.cxIdeal = rbBand.cx = 10;
rbBand.wID = ID_MYBUTTON;

// add test string to the combo box
AddStringToCB(hwndBtn);

// insert band
lr = SendMessage(hwndRB, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand);

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Please help me find out what's going wrong in my code.

And, why working this code, I noticed that my drop-down list do not have
a scroll bar, no matter how many items in it. If the height is not
enough, it just won't display them. But according to the MSDN, the
scroll bar should be displayed automatically. I am not sure if they're
related issues.

From: Christian ASTOR on
On 21 avr, 13:59, David Shen <davidshe...(a)googlemail.com> wrote:

> I am not using a Combo Box Listbox, I am using a Combo Box Drop-down
> box. And I have some test strings inserted into the Combo Box.

Yes, you are using a ComboLBox window, which is the Combo Box Listbox
part
As I said, its size is updated when the band is inserted and on others
events
You can use a ComboBoxEx32 instead..
From: David Shen on
Christian ASTOR wrote:
> On 21 avr, 13:59, David Shen <davidshe...(a)googlemail.com> wrote:
>
>> I am not using a Combo Box Listbox, I am using a Combo Box Drop-down
>> box. And I have some test strings inserted into the Combo Box.
>
> Yes, you are using a ComboLBox window, which is the Combo Box Listbox
> part
> As I said, its size is updated when the band is inserted and on others
> events
> You can use a ComboBoxEx32 instead..

Thanks a lot!!! ComboBoxEx32 solves my problem.

Looks like the old ComboBox should be retired...haha~~