-
Rebar problems
I'm trying to create a rebar but everything I put in it get's stretched to 100% of the rebar width, it's very weird and I can't see the problem.
I've already searched and gone over info at msdn relating to my problem and I turned up nothing that worked.
I'm using the following code to make rebars and bands:
Code:
HWND CreateReBar(HWND parent)
{
REBARINFO barInfo;
RECT rc;
HWND rebar;
rebar = CreateWindowEx(WS_EX_TOPMOST|WS_EX_TOOLWINDOW|WS_EX_LEFT|WS_EX_LTRREADING|WS_EX_RIGHTSCROLLBAR,
REBARCLASSNAME,
NULL,
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|RBS_VARHEIGHT|CCS_TOP|CCS_NODIVIDER,
0,0,0,0,
parent,
NULL,
GetModuleHandle(NULL),
NULL);
if(!rebar)
return NULL;
barInfo.cbSize = sizeof(REBARINFO);
barInfo.fMask = 0;
barInfo.himl = (HIMAGELIST)NULL;
return rebar;
}
void CreateBand(HWND rebar,char *bandText,HWND child)
{
REBARBANDINFO bandInfo;
RECT rc;
bandInfo.cbSize = sizeof(REBARBANDINFO);
bandInfo.fMask = RBBIM_COLORS|RBBIM_TEXT|RBBIM_STYLE|RBBIM_CHILD|
RBBIM_CHILDSIZE|RBBIM_SIZE;
bandInfo.fStyle = RBBS_CHILDEDGE|RBBS_GRIPPERALWAYS;
bandInfo.clrFore = RGB(0,0,0);
bandInfo.clrBack = GetSysColor(COLOR_BTNFACE);
GetClientRect(child,&rc);
bandInfo.lpText = bandText;
bandInfo.cch = lstrlen(bandInfo.lpText);
bandInfo.hwndChild = child;
bandInfo.cxMinChild = 20;
bandInfo.cyMinChild = rc.bottom - rc.top;
bandInfo.cx = 50;
SendMessage(rebar,RB_INSERTBAND,(WPARAM)-1,(LPARAM)&bandInfo);
}
-
You're not setting barInfo...
Code:
if (!SendMessage(rebar, RB_SETBARINFO, 0, (LPARAM)&barInfo))
return NULL;
Don't know if it will fix your problems.
Take a look at the example at the bottom of this page (if you haven't already).
gg
-
Yup, I've looked at that page before.. Also adding that message didn't seem to solve the problem at all.
This is most confusing. :confused:
-
I use these styles
S_VISIBLE | WS_BORDER | WS_CHILD | WS_CLIPCHILDREN |WS_CLIPSIBLINGS | CCS_NODIVIDER | CCS_NOPARENTALIGN| RBBS_FIXEDSIZE
You also don't set the tollbars ID when adding the band.
A child window must have the HMENU para cast to a unique int resource ID. You have set it to 0 or NULL.
ie
#define IDD_TOOLBAR 40001
(HMENU)IDD_TOOLBAR
-
I've tried using those styles, and I am assigning an ID thing to the child windows but I'm still getting the same result.
I've attached an image of what's happening.. As you can see the static with the text "test" is being stretched right to the edge of the rebar.. It does the same thing to any other child window I put in the band as well. .
-
try setting the band.cy
or at least zeroing the structure before you use it
ZeroMemory(&bandInfo,sizeof(REBARBANDINFO));
-
Ok, well I know why it does work... And I have no real reason to want it to work, I was just messing with the rebar control..
However I do have a new problem now.
Code:
CreateWindowEx(WS_EX_TOPMOST|WS_EX_TOOLWINDOW|WS_EX_LEFT|WS_EX_LTRREADING|WS_EX_RIGHTSCROLLBAR,
REBARCLASSNAME,
NULL,
(w>0?(WS_VISIBLE | WS_BORDER | WS_CHILD | WS_CLIPCHILDREN |WS_CLIPSIBLINGS | CCS_NODIVIDER | RBBS_FIXEDSIZE|CCS_VERT):(WS_VISIBLE | RBS_VARHEIGHT| WS_BORDER | WS_CHILD | WS_CLIPCHILDREN |WS_CLIPSIBLINGS | CCS_NODIVIDER | RBBS_FIXEDSIZE)),
0,0,(w>0?w:0),0,
parent,
NULL,
GetModuleHandle(NULL),
NULL);
I'm trying to make it so I can have a vertical rebar if I specify the width but I can't get it to span to that width ... I've tried heaps of different things but nothing seems to work properly.