Thread: Rebar problems

  1. #1

    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);
    }

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    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

  3. #3
    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.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    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
    Last edited by novacain; 11-18-2003 at 02:01 AM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    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. .

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    try setting the band.cy

    or at least zeroing the structure before you use it

    ZeroMemory(&bandInfo,sizeof(REBARBANDINFO));
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  7. #7
    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.

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. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  3. Rebar and ToolBars
    By underline_bruce in forum Windows Programming
    Replies: 4
    Last Post: 05-25-2007, 09:48 PM
  4. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 05:48 PM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 04:35 PM