From: Friedel Jantzen on
Am Tue, 22 Sep 2009 13:51:58 +0700 schrieb Nhat Dung:

> Hello, i'm sure 100% that is my code and i doesn't change anything.
> I also try to change
> REBARBANDINFO rbBand = { REBARBANDINFO_V6_SIZE };
> But that won't work :(

There was a combination of two problems.

First the size of the REBARBANDINFO struct; see the reply of "Men"
yesterday.

Second:
I assume, in your first version you created the toolbar and the combo as
child windows of the rebar, like in the MS sample. This is a *must*,
otherwise the rebar cannot manage them. This worked (together with the
correct size of the REBARBANDINFO struct for your compiler version).

I suppose, in the code you posted you changed the code and created the
toolbar and combo first and as child windows of the main window. Then you
passed the handles to your function HWND WINAPI CreateRebar(HWND hwndOwner,
HWND hwndToolbar, HWND hwndCombo), where you created your rebar and set the
handles in the rbBand struct. This cannot work.

If the members you indicate with the rbBand.fMask do not contain valid
data, the band will not be inserted, and
SendMessage(hwndRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbBand)
will return 0.

BTW: The relationship of windows is important in any application.

hth,
Friedel
From: Men on
The toolbar/combo window does not need to be child of the rebar window before RB_INSERTBAND.
Because RBInsertBand will call RBSetBandInfo to set the toolbar/combo window as child of the rebar window.

BOOL RBInsertBand(PRB prb, UINT uBand, LPREBARBANDINFO lprbbi)
{
PRBB prbb;
REBARBANDINFO rbbi = {0};

if (!prb || !RBValidateBandInfo(&lprbbi, &rbbi))
return(FALSE);
...
prbb = RBGETBAND(prb, uBand);
...
if (!RBSetBandInfo(prb, uBand, lprbbi, FALSE))
{
RBDeleteBand(prb, uBand);
return(FALSE);
}

...
RBSizeBandToRowHeight(prb, uBand, (UINT)-1);
...
}


BOOL RBSetBandInfo(PRB prb, UINT uBand, LPREBARBANDINFO lprbbi, BOOL fAllowRecalc)
{
...
PRBB prbb;
prbb = RBGETBAND(prb, uBand);
...
if (lprbbi->fMask & RBBIM_CHILD &&
lprbbi->hwndChild != prbb->hwndChild &&
(NULL == lprbbi->hwndChild ||
!IsChild(lprbbi->hwndChild, prb->ci.hwnd)))
{
if (IsWindow(prbb->hwndChild))
ShowWindow(prbb->hwndChild, SW_HIDE);

prbb->hwndChild = lprbbi->hwndChild;

if (prbb->hwndChild)
{
SetParent(prbb->hwndChild, prb->ci.hwnd);
ShowWindow(prbb->hwndChild, SW_SHOW);
}
fRecalc = TRUE;
}

...
}

"Friedel Jantzen" <nospam_plz(a)freenet.de> wrote:
> ...
> Second:
> I assume, in your first version you created the toolbar and the combo as
> child windows of the rebar, like in the MS sample. This is a *must*,
> otherwise the rebar cannot manage them.
> ...
From: Nhat Dung on
I'm sure 100%

<claus.kick(a)googlemail.com> wrote in message
news:42774dce-3f24-4e08-b8a2-05450b4d14a5(a)z34g2000vbl.googlegroups.com...
> On 21 Sep., 15:54, "Nhat Dung" <nhatd...(a)hotmail.com> wrote:
>> Thanks you all for help me :)
>> I had compile my code in VC6 + XP and everything work ... fine
>> Still can't understand why ???
>
> Are you sure you did use your original code?

From: Friedel Jantzen on
Hi,
Thank you for this useful clarification!
Nice that it works with SetParent, not relying on processing messages which
are sent during creation of the child windows...

Another question:
In the sample, a band was filled with a toolbar and rbBand.cx set to an
arbitrary value. Do you know, how to set the width (cx) of a band, so that
all buttons will be visible and no blank space will appear after the last
button?

TIA,
Friedel
From: Men on
1) Use TB_GETMAXSIZE to get the fitted width of the toolbar
2) then set this width as rbBand.cxMinChild,
3) let rbBand.cx alone (cx will be set by rebar itself),
4) after all bands are inserted (the band width of toolbar may be changed),
Use RB_MINIMIZEBAND to keep the band of toolbar fit.

With the following fixups to the sample code from "Nhat Dung", the band of toolbar looks fit.

/* #include "windows.h"
*/ #define _WIN32_WINNT 0x0501
#include "windows.h"

/* buttonStyles, {0}, 0, (INT_PTR)L"New" },
*/ buttonStyles, {0}, 0, (INT_PTR)TEXT("New") },

/* buttonStyles, {0}, 0, (INT_PTR)L"Open"},
*/ buttonStyles, {0}, 0, (INT_PTR)TEXT("Open") },

/* buttonStyles, {0}, 0, (INT_PTR)L"Save"}
*/ buttonStyles, {0}, 0, (INT_PTR)TEXT("Save") },

/* DWORD dwBtnSize = (DWORD)SendMessage(hwndToolbar, TB_GETBUTTONSIZE, 0,0);
*/ SIZE sizeTbar;
SendMessage(hwndToolbar, TB_GETMAXSIZE, 0, (LPARAM) &sizeTbar);

/* rbBand.cyChild = LOWORD(dwBtnSize);
rbBand.cxMinChild = 3 * HIWORD(dwBtnSize);
rbBand.cyMinChild = LOWORD(dwBtnSize);
*/ rbBand.cxMinChild = sizeTbar.cx;
rbBand.cyMinChild = sizeTbar.cy;

/* return (hwndRebar);
*/ WPARAM idbandTbar = 0;
SendMessage(hwndRebar, RB_MINIMIZEBAND, idbandTbar, 0);
return (hwndRebar);


"Friedel Jantzen" <nospam_plz(a)freenet.de> wrote:
> Hi,
> Thank you for this useful clarification!
> Nice that it works with SetParent, not relying on processing messages which
> are sent during creation of the child windows...
>
> Another question:
> In the sample, a band was filled with a toolbar and rbBand.cx set to an
> arbitrary value. Do you know, how to set the width (cx) of a band, so that
> all buttons will be visible and no blank space will appear after the last
> button?
>
> TIA,
> Friedel