티스토리 뷰

프로그래밍/API

폰트 공용 다이얼로그

에어버스 2016. 4. 16. 10:43

폰트 다이얼로그

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
47
48
#include <commdlg.h>
...
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static CHOOSEFONT font;
    static LOGFONT setfont;
    HFONT hFont, oldFont;
    TCHAR str[] = L"폰트 Test 1234";
    static bool fontflag = 0;
    switch (message)
    {
    case WM_COMMAND:
        {
            int wmId = LOWORD(wParam);
            // 메뉴 선택을 구문 분석합니다.
            switch (wmId)
            {
            case ID_FONT:
                font.lStructSize = sizeof(CHOOSEFONT);
                font.hwndOwner = hWnd;
                font.lpLogFont = &setfont;
                font.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_EFFECTS;
                if (ChooseFont(&font))
                {
                    fontflag = 1;
                    InvalidateRgn(hWnd, NULL, TRUE);
                }
                break;
 
    case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hWnd, &ps);
            // TODO: 여기에 hdc를 사용하는 그리기 코드를 추가합니다.
            if (fontflag)
            {
                hFont = CreateFontIndirect(&setfont);
                oldFont = (HFONT)SelectObject(hdc, hFont);
                TextOut(hdc, 100100, str, wcslen(str));
                SelectObject(hdc, oldFont);
                DeleteObject(hFont);
            }
            else
                TextOut(hdc, 100100, str, wcslen(str));
            EndPaint(hWnd, &ps);
        }
        break;
 
cs
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
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