WM_CTLCOLOR
-
Hi, I am using WM_CTLCOLOR to make the static text transparent and change the font and colour. Please can you tell me how to do the font-clean-up action if any is required here?
HBRUSH CF4_NewEstimate::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CResizableFormView::OnCtlColor(pDC, pWnd, nCtlColor);CFont \*m\_pFont = new CFont; m\_pFont->CreateFont(12,0,0,0,600,0,0,0,0,0,0,ANTIALIASED\_QUALITY,0,"MS Sans Serif"); CFont \*pOldFont = NULL;
// Make transparent static control
switch (nCtlColor)
{
case CTLCOLOR_STATIC:
pDC->SelectObject(m_pFont);
hbr = (HBRUSH)::GetStockObject (HOLLOW_BRUSH);
pDC->SetBkMode (TRANSPARENT);
pDC->SetTextColor(RGB(255,128,0));break; } return hbr;
}
Thanks.
_
Fortitudine Vincimus!_
-
Hi, I am using WM_CTLCOLOR to make the static text transparent and change the font and colour. Please can you tell me how to do the font-clean-up action if any is required here?
HBRUSH CF4_NewEstimate::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CResizableFormView::OnCtlColor(pDC, pWnd, nCtlColor);CFont \*m\_pFont = new CFont; m\_pFont->CreateFont(12,0,0,0,600,0,0,0,0,0,0,ANTIALIASED\_QUALITY,0,"MS Sans Serif"); CFont \*pOldFont = NULL;
// Make transparent static control
switch (nCtlColor)
{
case CTLCOLOR_STATIC:
pDC->SelectObject(m_pFont);
hbr = (HBRUSH)::GetStockObject (HOLLOW_BRUSH);
pDC->SetBkMode (TRANSPARENT);
pDC->SetTextColor(RGB(255,128,0));break; } return hbr;
}
Thanks.
_
Fortitudine Vincimus!_
Tara14 ase CTLCOLOR_STATIC: pDC->SelectObject(m_pFont);
This is not the correct way to change the font of a window. You should call the SetFont() function to change the font and this need to be done only once( in OnInitdialog() or OnIntitialUpdate() function etc ).
nave [OpenedFileFinder]