V
VickyCool4U
Guest
Hi
I am able to change the dialog title bar color with the following:-
void CMySampleDlg::OnNcPaint()
{
CDC* pDC = GetWindowDC();
CRect CapRct;
GetWindowRect(&CapRct);
long myFillColour = RGB(200, 0, 0);
long myTextColour = RGB(0, 0, 0);
int x1 = GetSystemMetrics(SM_CXDLGFRAME);
int y1 = GetSystemMetrics(SM_CYDLGFRAME);
int x2 = CapRct.Width() - GetSystemMetrics(SM_CXDLGFRAME);
int y2 = GetSystemMetrics(SM_CYICON) - GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYBORDER);
CapRct.left = x1;
CapRct.top = y1;
CapRct.right = x2;
CapRct.bottom = y2;
pDC->FillSolidRect(&CapRct, myFillColour);
CFont* pCurFont = GetFont();
LOGFONT lf;
pCurFont->GetLogFont (&lf);
lf.lfItalic = TRUE;
lf.lfWeight = FW_NORMAL;
lf.lfWidth = 12;
lf.lfHeight = 18;
strcpy(reinterpret_cast<char*>(lf.lfFaceName) ,"Veranda");
CFont capfont ;
capfont.CreateFontIndirect (&lf);
pCurFont = pDC->SelectObject (&capfont);
pDC->SetBkMode (TRANSPARENT);
pDC->SetTextColor (GetSysColor(COLOR_CAPTIONTEXT));
pDC->DrawText (_T("<Dialog Text>"), &CapRct, DT_CENTER | DT_VCENTER);
}
But when I apply the same in SDI application, it is giving assertion error pCurFont->GetLogFont (&lf); When debug the application found that afxwin2.inl->_AFXWIN_INLINE CFont* CWnd::GetFont() const
retuning null for CFont* pCurFont = GetFont();
I found that null mean , it is using system font.
Can anybody suggest me , how to resolve the same or If there is better medium to do so. I would like to change the color of title bar including setting the font for the caption of title bar and close button should be available as well
Continue reading...
I am able to change the dialog title bar color with the following:-
void CMySampleDlg::OnNcPaint()
{
CDC* pDC = GetWindowDC();
CRect CapRct;
GetWindowRect(&CapRct);
long myFillColour = RGB(200, 0, 0);
long myTextColour = RGB(0, 0, 0);
int x1 = GetSystemMetrics(SM_CXDLGFRAME);
int y1 = GetSystemMetrics(SM_CYDLGFRAME);
int x2 = CapRct.Width() - GetSystemMetrics(SM_CXDLGFRAME);
int y2 = GetSystemMetrics(SM_CYICON) - GetSystemMetrics(SM_CYDLGFRAME) - GetSystemMetrics(SM_CYBORDER);
CapRct.left = x1;
CapRct.top = y1;
CapRct.right = x2;
CapRct.bottom = y2;
pDC->FillSolidRect(&CapRct, myFillColour);
CFont* pCurFont = GetFont();
LOGFONT lf;
pCurFont->GetLogFont (&lf);
lf.lfItalic = TRUE;
lf.lfWeight = FW_NORMAL;
lf.lfWidth = 12;
lf.lfHeight = 18;
strcpy(reinterpret_cast<char*>(lf.lfFaceName) ,"Veranda");
CFont capfont ;
capfont.CreateFontIndirect (&lf);
pCurFont = pDC->SelectObject (&capfont);
pDC->SetBkMode (TRANSPARENT);
pDC->SetTextColor (GetSysColor(COLOR_CAPTIONTEXT));
pDC->DrawText (_T("<Dialog Text>"), &CapRct, DT_CENTER | DT_VCENTER);
}
But when I apply the same in SDI application, it is giving assertion error pCurFont->GetLogFont (&lf); When debug the application found that afxwin2.inl->_AFXWIN_INLINE CFont* CWnd::GetFont() const
retuning null for CFont* pCurFont = GetFont();
I found that null mean , it is using system font.
Can anybody suggest me , how to resolve the same or If there is better medium to do so. I would like to change the color of title bar including setting the font for the caption of title bar and close button should be available as well
Continue reading...