Dialog base 프로그램의 다이얼로그의 배경색은 기본값이 회색이죠.
이 우중충한 회색은 눈이 편하다는 것 말고는 그다시 실용성이 없어 보입니다.
1. 우선 컨트롤+W를 눌러 클래스 위저드를 실행시킵니다.
2. Message Maps 탭을 선택하고, Object IDs에서 다이얼로그의 ID를 선택합니다.
그리고 우측 Messages에서 WM_CTLCOLOR를 더블클릭하여 메세지맵을 추가합니다.
3. Edit code를 눌러 아래와 같이 코딩합니다.
HBRUSH TestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch(nCtlColor)
{
case CTLCOLOR_DLG:
return (HBRUSH)GetStockObject(WHITE_BRUSH);
break;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
컨틀롤과 브러시는 아래와 같이 정의되어 있습니다.
#define CTLCOLOR_MSGBOX 0
#define CTLCOLOR_EDIT 1
#define CTLCOLOR_LISTBOX 2
#define CTLCOLOR_BTN 3
#define CTLCOLOR_DLG 4
#define CTLCOLOR_SCROLLBAR 5
#define CTLCOLOR_STATIC 6
#define CTLCOLOR_MAX 7
#define WHITE_BRUSH 0
#define LTGRAY_BRUSH 1
#define GRAY_BRUSH 2
#define DKGRAY_BRUSH 3
#define BLACK_BRUSH 4
#define NULL_BRUSH 5
#define HOLLOW_BRUSH NULL_BRUSH
#define WHITE_PEN 6
#define BLACK_PEN 7
#define NULL_PEN 8
#define OEM_FIXED_FONT 10
#define ANSI_FIXED_FONT 11
#define ANSI_VAR_FONT 12
#define SYSTEM_FONT 13
#define DEVICE_DEFAULT_FONT 14
#define DEFAULT_PALETTE 15
#define SYSTEM_FIXED_FONT 16
이 우중충한 회색은 눈이 편하다는 것 말고는 그다시 실용성이 없어 보입니다.
1. 우선 컨트롤+W를 눌러 클래스 위저드를 실행시킵니다.
2. Message Maps 탭을 선택하고, Object IDs에서 다이얼로그의 ID를 선택합니다.
그리고 우측 Messages에서 WM_CTLCOLOR를 더블클릭하여 메세지맵을 추가합니다.
3. Edit code를 눌러 아래와 같이 코딩합니다.
HBRUSH TestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch(nCtlColor)
{
case CTLCOLOR_DLG:
return (HBRUSH)GetStockObject(WHITE_BRUSH);
break;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
컨틀롤과 브러시는 아래와 같이 정의되어 있습니다.
#define CTLCOLOR_MSGBOX 0
#define CTLCOLOR_EDIT 1
#define CTLCOLOR_LISTBOX 2
#define CTLCOLOR_BTN 3
#define CTLCOLOR_DLG 4
#define CTLCOLOR_SCROLLBAR 5
#define CTLCOLOR_STATIC 6
#define CTLCOLOR_MAX 7
#define WHITE_BRUSH 0
#define LTGRAY_BRUSH 1
#define GRAY_BRUSH 2
#define DKGRAY_BRUSH 3
#define BLACK_BRUSH 4
#define NULL_BRUSH 5
#define HOLLOW_BRUSH NULL_BRUSH
#define WHITE_PEN 6
#define BLACK_PEN 7
#define NULL_PEN 8
#define OEM_FIXED_FONT 10
#define ANSI_FIXED_FONT 11
#define ANSI_VAR_FONT 12
#define SYSTEM_FONT 13
#define DEVICE_DEFAULT_FONT 14
#define DEFAULT_PALETTE 15
#define SYSTEM_FIXED_FONT 16