Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Using a Dialog Bar with a Rebar Control.
As mentioned in Rebar Controls and Bands, each band can contain only one child window (or control). This might be a limitation if you want to have more than one child window per band. A convenient workaround is to create a dialog bar resource with multiple controls and then add a rebar band (containing the dialog bar) to the rebar control.
Normally, if you wanted the dialog bar band to appear transparent, you would set the WS_EX_TRANSPARENT extended style for the dialog bar object. However, because WS_EX_TRANSPARENT has some issues with properly painting the background of a dialog bar, you will need to do a little extra work to achieve the desired effect.
The following procedure details the steps necessary to achieve transparency without using the WS_EX_TRANSPARENT extended style.
To implement a transparent dialog bar in a rebar band
Using the Add Class dialog box, add a new class (for example,
CMyDlgBar) that implements your dialog bar object.Add a handler for the
WM_ERASEBKGNDmessage.In the new handler, modify the existing code to match the following example:
BOOL CMyDlgBar::OnEraseBkgnd(CDC* pDC) { CWnd* pParent = GetParent(); ASSERT_VALID(pParent); CPoint pt(0, 0); MapWindowPoints(pParent, &pt, 1); pt = pDC->OffsetWindowOrg(pt.x, pt.y); LRESULT lResult = pParent->SendMessage(WM_ERASEBKGND, (WPARAM)pDC->m_hDC, 0L); pDC->SetWindowOrg(pt.x, pt.y); return (BOOL)lResult; }Add a handler for the
WM_MOVEmessage.In the new handler, modify the existing code to match the following example:
void CMyDlgBar::OnMove(int x, int y) { UNREFERENCED_PARAMETER(x); UNREFERENCED_PARAMETER(y); Invalidate(); }
The new handlers simulate the transparency of the dialog bar by forwarding the WM_ERASEBKGND message to the parent window and forcing a repaint every time the dialog bar object is moved.