1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
// ------------------------------------------------------
void CTestsDiversDlg::InitBkSolidBrush(COLORREF BkColorRef)
{
// m_pBkBrush est à null dans le constructeur et ne pas oulier la sequence suivante dans le destructeur
if(m_pBkBrush)
{
m_pBkBrush->DeleteObject();
delete m_pBkBrush;
}
m_pBkBrush = new CBrush;
m_pBkBrush->CreateSolidBrush(BkColorRef);
}
HBRUSH CTestsDiversDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// par exemple en fonction de nCtlColor voir doc.
switch(nCtlColor)
{
case CTLCOLOR_DLG:
case CTLCOLOR_STATIC :
// Set the text color to red.
pDC->SetTextColor(RGB(255, 0, 0));
// Set the background mode for text to transparent
// so background will show thru.
pDC->SetBkMode(TRANSPARENT);
// Return handle to our CBrush object.
if(nCtlColor==CTLCOLOR_DLG && m_pBkBrush) hbr=(HBRUSH)m_pBkBrush->GetSafeHandle();
break;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
// utilisation
CTestsDiversDlg Dlg;
Dlg.InitBkSolidBrush(RGB(0xFF, 0xFF, 0xE0));
Dlg.DoModal(); |