Rebar Band problem

This is a discussion on Rebar Band problem within the Windows Programming forums, part of the Platform Specific Boards category; Hi ppl, well do anybody here know what's problem with this code, so he don't draw combobox, just show toolbar. ...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    3

    Rebar Band problem

    Hi ppl, well do anybody here know what's problem with this code, so he don't draw combobox, just show toolbar.
    I mean he show last drawen control before call last "RB_SETREBARBANDINFO", in this case it its a Toolbar, if I put combobox in his place, and toolbar on place toolbar, than he draw just cobmobox. So why he draw just one control when i want 2 controls in 2 bands.

    So I waiting for help

    Code:
    class REBARCLASS
    {
    public:
    	REBARCLASS(){
    	succ = true; 
    	ToolbarID[0] = 2301;
    	ToolbarID[1] = 2302;
    	ToolbarID[2] = 2303;
    	ToolbarID[3] = 2304;
    	};
    	~REBARCLASS(){;};
    	HWND hwndCB;
    	HWND hwndTB;
    	HWND hwndRB;
    	REBARINFO RBI;
    	REBARBANDINFO RBBI;
    	TBBUTTON tb[4];
    	HIMAGELIST hil;
    	RECT RC;
    	HBITMAP hToolbarImage;
    	DWORD dwBtnSize;
    	int itextToobar[4];
    	int ToolbarID[4];
    	bool succ;
    	bool CreateReber(HWND&, REBARCLASS&, HINSTANCE&);
    };
    
    bool REBARCLASS::CreateReber(HWND& hwnd, REBARCLASS& rbc, HINSTANCE& hInst)
    {
    
    	rbc.hwndRB = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, 
    		WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN  
    		| RBS_BANDBORDERS | CCS_NODIVIDER  | RBS_VARHEIGHT, 
    		0, 0, 0, 0, hwnd, NULL, hInst, NULL);;
    	
    	if(!rbc.hwndRB)
    	{
    	errmsg(GetLastError(), "Create Window");
    	return 0;
    	}
    
    	rbc.RBI.cbSize = sizeof(REBARINFO);
    	rbc.RBI.fMask = 0;
    	rbc.RBI.himl = (HIMAGELIST)NULL;
    	
    	if(!SendMessage(rbc.hwndRB, RB_SETBARINFO, 0, (LPARAM)&rbc.RBI))
    	{
    	errmsg(GetLastError(), "Set Control");
    	return 0;
    	}
    
    
    	rbc.RBBI.cbSize = sizeof(REBARBANDINFO);
    	rbc.RBBI.fMask = RBBIM_COLORS | RBBIM_TEXT | RBBIM_BACKGROUND | 
                       RBBIM_STYLE | RBBIM_CHILD  | RBBIM_CHILDSIZE | 
                       RBBIM_SIZE;
    	rbc.RBBI.fStyle = RBBS_CHILDEDGE | RBBS_VARIABLEHEIGHT | RBBS_GRIPPERALWAYS;
    	
    
    	rbc.hwndCB = CreateWindowEx(NULL, "COMBOBOX", NULL, WS_CHILD | WS_VISIBLE  | CBS_SORT | CBS_DROPDOWN, 
    		0, 10, 100, 26, rbc.hwndRB, NULL, hInst, NULL);
    	SendMessage(rbc.hwndCB, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), NULL);
    
    	GetWindowRect(rbc.hwndCB, &rbc.RC);
    
    	rbc.tb[0].fsState = TBSTATE_ENABLED;
    	rbc.tb[0].fsStyle = TBSTYLE_BUTTON;
    	rbc.tb[0].iBitmap = 1;
    	rbc.tb[0].idCommand = rbc.ToolbarID[0];
    	rbc.tb[0].iString = rbc.itextToobar[0];
    
    	rbc.tb[1].fsState = TBSTATE_ENABLED;
    	rbc.tb[1].fsStyle = TBSTYLE_BUTTON;
    	rbc.tb[1].iBitmap = 2;
    	rbc.tb[1].idCommand = rbc.ToolbarID[1];
    	rbc.tb[1].iString = rbc.itextToobar[1];
    
    	rbc.tb[2].fsState = TBSTATE_ENABLED;
    	rbc.tb[2].fsStyle = TBSTYLE_BUTTON;
    	rbc.tb[2].iBitmap = 3;
    	rbc.tb[2].idCommand = rbc.ToolbarID[2];
    	rbc.tb[2].iString = rbc.itextToobar[2];
    
    	rbc.tb[3].fsState = TBSTATE_ENABLED;
    	rbc.tb[3].fsStyle = TBSTYLE_BUTTON;
    	rbc.tb[3].iBitmap = 4;
    	rbc.tb[3].idCommand = rbc.ToolbarID[3];
    	rbc.tb[3].iString = rbc.itextToobar[3];
    
    
    	if(!(rbc.hwndTB = CreateWindowEx(NULL, TOOLBARCLASSNAME, NULL, 
    		WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | 
    		TBSTYLE_TOOLTIPS | TBSTYLE_LIST | CCS_NORESIZE | CCS_NODIVIDER,
    		0, 0, 0, 0, rbc.hwndRB, NULL, hInst, NULL)))
    		errmsg(GetLastError(), "Create Toolbar");
    
    	SendMessage(rbc.hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), NULL);
    	SendMessage(rbc.hwndTB, TB_SETIMAGELIST, 0, (LPARAM)rbc.hil);
    	SendMessage(rbc.hwndTB, TB_ADDBUTTONS, (WPARAM) 4, (LPARAM) &rbc.tb);
    
    	rbc.dwBtnSize = SendMessage(rbc.hwndTB, TB_GETBUTTONSIZE, 0, 0);
    	
    
    	SendMessage(rbc.hwndRB, RB_INSERTBAND, (WPARAM)NULL, (LPARAM)&rbc.RBBI);
    
    	rbc.RBBI.lpText     = "Address";
    	rbc.RBBI.hwndChild  = rbc.hwndCB;
    	rbc.RBBI.cxMinChild = rbc.RC.bottom - rbc.RC.top;
    	rbc.RBBI.cyMinChild = 32;
    	rbc.RBBI.cx         = 10;
    	
    	SendMessage(rbc.hwndRB, RB_SETBANDINFO, NULL, (LPARAM)&rbc.RBBI);;
    	
    
    	SendMessage(rbc.hwndRB, RB_INSERTBAND, (WPARAM)NULL, (LPARAM)&rbc.RBBI);
    
    	rbc.RBBI.lpText = "Tool bar";
    	rbc.RBBI.hwndChild = rbc.hwndTB;
    	rbc.RBBI.cxMinChild = HIWORD(rbc.dwBtnSize)*2;;
    	rbc.RBBI.cyMinChild = 32;
    	rbc.RBBI.cx = 0;
    
    	SendMessage(rbc.hwndRB, RB_SETBANDINFO, NULL, (LPARAM)&rbc.RBBI);
    
    	
    	return rbc.succ;
    };

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    According to the documentation, the WPARAM argument for the RB_SETBANDINFO message specifies the zero-based index of the band to receive the new settings. By passing NULL both calls, you are setting the info for the first band twice. The solution is simple, just pass the correct band number:
    Code:
    	SendMessage(rbc.hwndRB, RB_SETBANDINFO, 0, (LPARAM)&rbc.RBBI);;
    	
    
    	SendMessage(rbc.hwndRB, RB_INSERTBAND, (WPARAM)NULL, (LPARAM)&rbc.RBBI);
    
    	rbc.RBBI.lpText = "Tool bar";
    	rbc.RBBI.hwndChild = rbc.hwndTB;
    	rbc.RBBI.cxMinChild = HIWORD(rbc.dwBtnSize)*2;;
    	rbc.RBBI.cyMinChild = 32;
    	rbc.RBBI.cx = 0;
    
    	SendMessage(rbc.hwndRB, RB_SETBANDINFO, 1, (LPARAM)&rbc.RBBI);

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    3
    Quote Originally Posted by anonytmouse
    According to the documentation, the WPARAM argument for the RB_SETBANDINFO message specifies the zero-based index of the band to receive the new settings. By passing NULL both calls, you are setting the info for the first band twice. The solution is simple, just pass the correct band number:
    Code:
    	SendMessage(rbc.hwndRB, RB_SETBANDINFO, 0, (LPARAM)&rbc.RBBI);;
    	
    
    	SendMessage(rbc.hwndRB, RB_INSERTBAND, (WPARAM)NULL, (LPARAM)&rbc.RBBI);
    
    	rbc.RBBI.lpText = "Tool bar";
    	rbc.RBBI.hwndChild = rbc.hwndTB;
    	rbc.RBBI.cxMinChild = HIWORD(rbc.dwBtnSize)*2;;
    	rbc.RBBI.cyMinChild = 32;
    	rbc.RBBI.cx = 0;
    
    	SendMessage(rbc.hwndRB, RB_SETBANDINFO, 1, (LPARAM)&rbc.RBBI);
    Hmmm, I changed it, but no difference, any other idea ?

  4. #4
    Registered User
    Join Date
    Jul 2006
    Posts
    3
    I fix it, both RB_INSERTBAND calls must be before both RB_SETBANDINFO calls. Now its works.
    And sure I need to put correct band number like WPARAM.
    thx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cannot insert toolbar into rebar
    By supernater in forum Windows Programming
    Replies: 1
    Last Post: 06-02-2009, 03:35 AM
  2. Rebar and ToolBars
    By underline_bruce in forum Windows Programming
    Replies: 4
    Last Post: 05-25-2007, 09:48 PM
  3. Vertical rebar, not wide enough
    By Mithoric in forum Windows Programming
    Replies: 8
    Last Post: 12-03-2003, 03:22 AM
  4. Rebar problems
    By Mithoric in forum Windows Programming
    Replies: 6
    Last Post: 11-19-2003, 04:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21