티스토리 뷰
commdlg.h 포함 시킴.
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
41
42
43
44
45
46 |
#include <commdlg.h>
...
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static CHOOSECOLOR color;
static COLORREF setColor;
static COLORREF crCustColors[16];
switch (message)
{
case WM_COMMAND:
{
int wmId = LOWORD(wParam);
// 메뉴 선택을 구문 분석합니다.
switch (wmId)
{
case ID_COLOR:
setColor = RGB(0, 0, 0);
color.hwndOwner = hWnd;
color.lStructSize = sizeof(CHOOSECOLOR);
color.rgbResult = setColor;
color.Flags = CC_RGBINIT | CC_FULLOPEN;
color.lpCustColors = crCustColors;
if (ChooseColor(&color))
InvalidateRgn(hWnd, NULL, TRUE);
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
// TODO: 여기에 hdc를 사용하는 그리기 코드를 추가합니다.
if (fontflag)
{
SetTextColor(hdc, color.rgbResult); // 폰트에 선택한 컬러설정
hFont = CreateFontIndirect(&setfont);
oldFont = (HFONT)SelectObject(hdc, hFont);
TextOut(hdc, 100, 100, str, wcslen(str));
SelectObject(hdc, oldFont);
DeleteObject(hFont);
}
else
TextOut(hdc, 100, 100, str, wcslen(str));
EndPaint(hWnd, &ps);
}
break; |
cs |