Using an Image List with a Rebar Control

OverviewSample

Each rebar band can contain, among other things, an image from an associated image list. The following procedure details the necessary steps for displaying an image in a rebar band.

To display images in a rebar band

  1. Attach an image list to your rebar control object by making a call to , passing a pointer to an existing image list.

  2. Modify the REBARBANDINFO structure to assign an image to a rebar band:

    • Set the fMask member to RBBIM_IMAGE, using the bitwise OR operator to include additional flags as necessary.

    • Set the iImage member to the image list index of the image to be displayed.

  3. Initialize any remaining data members, such as the size, text, and handle of the contained child window, with the necessary information.

  4. Insert the new band (with the image) with a call to , passing the REBARBANDINFO structure.

The following example assumes that an existing image list object with two images was attached to the rebar control object (m_wndReBar). A new rebar band (defined by rbi), containing the first image, is added with a call to InsertBand:

REBARBANDINFO rbi;
rbi.cbSize= sizeof(REBARBANDINFO);
rbi.fMask= RBBIM_BACKGROUND | RBBIM_CHILD | RBBIM_IMAGE | RBBIM_CHILDSIZE | RBBIM_STYLE | RBBIM_TEXT;
rbi.fStyle= RBBS_GRIPPERALWAYS;
rbi.cxMinChild= 200;
rbi.cyMinChild= 50;
rbi.lpText= "Band #1";
rbi.cch= 7;
rbi.cx= 300;
rbi.hbmBack= (HBITMAP)m_bmap3;
rbi.iImage= 0;
rbi.hwndChild= (HWND)m_wndToolBar;
BOOL bRes= m_wndReBar.InsertBand(-1, &rbi);

See Also   Windows Common Controls and MFC Classes