Rezolvare: Se deriveaza o clasa din CToolBar, sa zicem CToolBarExt. Apoi se suprascriu metodele urmatoare:
Code: Select all
// ToolBarExt.h : header file
class CToolBarExt : public CToolBar
{
// Construction
public:
CToolBarExt();
// Operations
public:
void DrawGripper(CDC* pDC, const CRect& rect);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CToolBarExt)
virtual void DoPaint(CDC* pDC);
virtual CSize CalcDynamicLayout(int nLength, DWORD dwMode);
//}}AFX_VIRTUAL
protected:
//{{AFX_MSG(CToolBarExt)
afx_msg void OnNcPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
Code: Select all
// ToolBarExt.cpp : implementation file
BEGIN_MESSAGE_MAP(CToolBarExt, CToolBar)
//{{AFX_MSG_MAP(CToolBarExt)
ON_WM_NCPAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CToolBarExt::DoPaint(CDC* pDC)
{
ASSERT_VALID(this);
ASSERT_VALID(pDC);
// Paint inside the client area.
CRect rect;
GetClientRect(rect);
DrawBorders(pDC, rect);
DrawGripper(pDC, rect);
}
void CToolBarExt::OnNcPaint()
{
// Get window DC that is clipped to the non-client area.
CWindowDC dc(this);
CRect rectClient;
GetClientRect(rectClient);
CRect rectWindow;
GetWindowRect(rectWindow);
ScreenToClient(rectWindow);
rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
dc.ExcludeClipRect(rectClient);
// Draw the borders in the non-client area.
rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);
DrawBorders(&dc, rectWindow);
// Erase the parts that are not drawn.
dc.IntersectClipRect(rectWindow);
SendMessage(WM_ERASEBKGND, (WPARAM)dc.m_hDC);
// Draw the gripper in the non-client area.
DrawGripper(&dc, rectWindow);
}
void CToolBarExt::DrawGripper(CDC* pDC, const CRect& rect)
{
pDC->FillSolidRect(&rect, ::GetSysColor(COLOR_BTNFACE)); // Fill in the background.
CToolBar::DrawGripper(pDC,rect);
}
Code: Select all
...
...
// CToolBar m_wndToolBar;
CToolBarExt m_wndToolBar;
Atasez aici si o mica aplicatie de test .