CStatic 및 컨트롤러에 배경 투명화시키기
BEGIN_MESSAGE_MAP(CRCS_Client_ProDlg, CDialog)
//{{AFX_MSG_MAP(CRCS_Client_ProDlg)
ON_WM_CTLCOLOR() // 컨트롤러에 색 입힐 때 호출됨.
// OnDraw 호출시기와 비슷함.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
:
:
HBRUSH CDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
pDC->SetBkMode(OPAQUE);
switch(nCtlColor)
{
case CTLCOLOR_STATIC:
pDC->SetBkColor(RGB(209,210,212));
pDC->SetTextColor(RGB(0,0,0));
hbr = (HBRUSH)GetStockObject(NULL_BRUSH);
break;
}
return hbr;
}
// 부가적으로 기능을 더 추가하고 싶다면..
#define BG_COLOR RGB(234,235,235)
#define STATIC_CLASS_T("Static")
#define BUTTON_CLASS_T("Button")
:
:
HBRUSH CDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor == CTLCOLOR_STATIC) //Static Text가 그려질 때..
{
TCHAR lpszClassName [256];
::GetClassName(pWnd->GetSafeHwnd(), lpszClassName, 255);
CString strClass = lpszClassName;
if (strClass == STATIC_CLASS)
{
pDC->SetBkMode(TRANSPARENT);
return(HBRUSH) ::GetStockObject(HOLLOW_BRUSH);
}
if (strClass == BUTTON_CLASS) //Radio Button의 텍스트가 그려질 때..
{
pDC->SetBkColor(BG_COLOR); //group box
}
return(HBRUSH) ::GetStockObject(HOLLOW_BRUSH); //(NULL_BRUSH = HOLLOW_BRUSH)
}
return hbr;
}
*** 참고사항 ***
'NativeCode > mfc' 카테고리의 다른 글
부모윈도우 호출 (0) | 2010.03.18 |
---|---|
좌표, 영역 관련 함수 (0) | 2010.03.18 |
CStringArray (0) | 2010.03.18 |
SendMessage 종류 (0) | 2010.03.18 |
SendMessage (0) | 2010.03.18 |