I'm upgrading an old MFC project to use the MFC Feature Pack and Ribbon. I changed a pane derived from CControlBar to be derived from CDockablePane and it works great, however it still looks old and does not blend with the ribbon look and theme. The Pane also has buttons that still look old.
How do I change the look, feel or theme of a CDockablePane derived object and buttons derived from CButton?
I'm using the following code to draw the button, is the best way to simply change the background?
void CFolderButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
UINT uState=DFCS_BUTTONPUSH;
if( lpDrawItemStruct->itemState & ODS_SELECTED )
{
uState|=DFCS_PUSHED;
}
//CDC dc;
CDC* dc = CDC::FromHandle(lpDrawItemStruct->hDC);
dc->DrawFrameControl(&lpDrawItemStruct->rcItem,DFC_BUTTON,uState);
if( !IsWindowEnabled() )
{
dc->SetTextColor(::GetSysColor(COLOR_3DSHADOW));
}
CString csText;
GetWindowText(csText);
if (m_iDisplayType != 2 || !m_hIcon)
{
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = m_iFontSize;
strcpy(lf.lfFaceName, "Tahoma Bold");
VERIFY(font.CreateFontIndirect(&lf));
CFont* def_font = dc->SelectObject(&font);
RECT buttonRect = lpDrawItemStruct->rcItem;
buttonRect.left += 10;
buttonRect.right += 10;
if (m_iDisplayType != 1 || !m_hIcon) //text & Icon
{
buttonRect.left += 30;
buttonRect.right += 30;
}
dc->DrawText(csText,&buttonRect,DT_LEFT|DT_SINGLELINE|DT_VCENTER);
dc->SelectObject(def_font);
font.DeleteObject();
}
if (m_hIcon && m_iDisplayType != 1)
{
CSize czText = dc->GetTextExtent(csText);
dc->DrawIcon(0,0,m_hIcon);
}
}
The following image shows the contrast between the buttons and the ribbon: