2008. 10. 3. 20:23

Text Color, Control BackGround Color

textColor_Test.zip

HBRUSH CTextColor_TestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
 HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
 
 // TODO: Change any attributes of the DC here
 if( pWnd->GetDlgCtrlID() == IDC_EDIT_TEXTCOLOR ) {

  if( !Complete )   // 플러그값에 따른 설정
  {
       pDC->SetTextColor( RGB(255,0,0));         // Font 색깔
  }
  else
  {
       pDC->SetTextColor( RGB(255,255,255));         // Font 색깔
  }
  // Control 배경처리
  pDC->SetBkColor( RGB(0,0,0));
  CFont    font;
 //  Font및 size
  font.CreateFont(14, 0, 0, 0, FW_SEMIBOLD, FALSE, FALSE, 0, 0, 0, 0, 0, 0, "Letha");  
  CFont *Oldfont= (CFont*) pDC->SelectObject(&font);
  hbr = (HBRUSH)GetStockObject(BLACK_BRUSH);
 }


 // TODO: Return a different brush if the default is not desired
 return hbr;
}

 

  WM_CTLCOLOR 메시지 처리 함수를 정의한 뒤 안에 각 상황에 따라 바뀌는 색에 대한 플러그

를 세팅해주고 다른 함수에서는  RedrawWindow()함수로 호출하도록 하면 된다.