zoukankan      html  css  js  c++  java
  • 第17章 文本和字体_17.4 字体枚举

    17.4 字体枚举

    17.4.1 枚举函数

    (1)EnumFontFamiliesEx函数

    参数

    含义

    HDC hdc

    handle to DC

    LPLOGFONT lpLogfont

    传入LOGFONT结构的指针

    注意:如果lfCharset=DEFAULT_CHARSET;

    lf.lfFaceName[0]=NULL,则枚举所有字体

    FONTENUMPROC lpEnumFontFamExProc

    枚举回调函数

    LPARAM lParam

    可以指定附加数据,会传到枚举的回调函数中

    DWORD dwFlags

    没用,必须为0

    (2)EnumFontFamExProc回调函数(在每找到一种字体,该函数就被调用一次)

     

    参数

    含义

    ENUMLOGFONTEX *lpelfe

    指向含有字体的逻辑属性的ENUMLOGFONTEX结构的指针

    NEWTEXTMETRICEX *lpntme

    指向含有字体物理属性的结构的指针

    DWORD FontType

    指定字体类型,此参数可为下列值的组合。

    DEVICE_FONTTYPE, RASTER_FONTTYPE, TRUETYPE_FONTTYPE

    LPARAM lParam

    由EnumFontFamiliesEx中lParam指定的数据

    【EnumFont程序】枚举计算机上的所有字体

    /*------------------------------------------------------------
    ENUMFONT.C -- EnumFontFamiliesEx函数
    (c) Charles Petzold, 1998
    ------------------------------------------------------------*/
    #include <windows.h>
    #define ID_LIST 1
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX*, NEWTEXTMETRICEX*, DWORD, LPARAM);
    int DisplayFonts(HWND hwnd, HDC hdc);
    typedef struct
    {
        HWND hwndList;
        int iCount;
    } EnumData;
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                       PSTR szCmdLine, int iCmdShow)
    {
        static TCHAR szAppName[] = TEXT("EnumFont");
        HWND         hwnd;
        MSG          msg;
        WNDCLASSEX     wndclass;
        wndclass.style = CS_HREDRAW | CS_VREDRAW;
        wndclass.cbSize = sizeof(WNDCLASSEX);
        wndclass.lpfnWndProc = WndProc;
        wndclass.cbClsExtra = 0;
        wndclass.cbWndExtra = 0;
        wndclass.hInstance = hInstance;
        wndclass.hIcon = LoadIcon(hInstance, szAppName);
        wndclass.hIconSm = LoadIcon(hInstance, szAppName);
        wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
        wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
        wndclass.lpszMenuName = NULL;
        wndclass.lpszClassName = szAppName;
        if (!RegisterClassEx(&wndclass))
        {
            MessageBox(NULL, TEXT("This program requires Windows NT!"),
                       szAppName, MB_ICONERROR);
            return 0;
        }
    
        hwnd = CreateWindow(szAppName,                  // window class name
                            TEXT("利用EnumFontFamiliesEx枚举字体"), // window caption
                            WS_OVERLAPPEDWINDOW,        // window style
                            CW_USEDEFAULT,              // initial x position
                            CW_USEDEFAULT,              // initial y position
                            560,              // initial x size
                            480,              // initial y size
                            NULL,                       // parent window handle
                            NULL,                       // window menu handle
                            hInstance,                  // program instance handle
                            NULL);                     // creation parameters
    
        ShowWindow(hwnd, iCmdShow);
        UpdateWindow(hwnd);
    
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        return msg.wParam;
    }
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        HDC         hdc;
        PAINTSTRUCT ps;
        static int cxChar, cyChar;
        static TEXTMETRIC tm;
        static HWND hwndList;
        static int iCount;
        TCHAR szBuffer[50];
        switch (message)
        {
        case WM_CREATE:
            cxChar = LOWORD(GetDialogBaseUnits());
            cyChar = HIWORD(GetDialogBaseUnits());
            hwndList = CreateWindow(TEXT("listbox"), NULL,
                                    WS_CHILD | WS_VISIBLE | LBS_STANDARD,
                                    cxChar, cyChar * 3,
                                    cxChar * LF_FULLFACESIZE + GetSystemMetrics(SM_CXVSCROLL),
                                    cyChar * 25,
                                    hwnd, (HMENU)ID_LIST,
                                    (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE),
                                    NULL);
            hdc = GetDC(hwnd);
            iCount = DisplayFonts(hwndList, hdc);
            ReleaseDC(hwnd, hdc);
            return 0;
        case WM_PAINT:
            hdc = BeginPaint(hwnd, &ps);
            TextOut(hdc, 10, 20, szBuffer, wsprintf(szBuffer, TEXT("共有%d种字体"), iCount));
            EndPaint(hwnd, &ps);
            return 0;
        case WM_SETFOCUS:
            SetFocus(hwndList);
            return 0;
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
        }
        return DefWindowProc(hwnd, message, wParam, lParam);
    }
    int DisplayFonts(HWND hwnd, HDC hdc)
    {
        EnumData ed;
        LOGFONT lf;
        //以下两个设置表示枚举所有的字体
        lf.lfCharSet = DEFAULT_CHARSET;
        lf.lfFaceName[0] = '';
        ed.iCount = 0;
        ed.hwndList = hwnd;
        //枚举字体,并显示在列表框中
        EnumFontFamiliesEx(hdc, (LPLOGFONT)&lf, (FONTENUMPROC)EnumFontFamExProc, (LPARAM)&ed, 0);
        return ed.iCount;
    }
    int CALLBACK EnumFontFamExProc(
        ENUMLOGFONTEX *lpelfe,    // logical-font data
        NEWTEXTMETRICEX *lpntme,  // physical-font data
        DWORD FontType,           // type of font
        LPARAM lParam)            // application-defined data
    {
        EnumData* ped = (EnumData*)lParam;
        SendMessage(ped->hwndList, LB_ADDSTRING, 0, (LPARAM)lpelfe->elfFullName);
        //TextOut(ped->hdc, ped->x, ped->y, lpelfe->elfFullName, lstrlen(lpelfe->elfFullName));
        ped->iCount++;
        return TRUE;
    }

    17.4.2 ChooseFont对话框

    (1)CHOOSEFONT结构

    字段

    含义

    lStructSize

    结构体长度

    hwndOwner

    所属窗口

    hdc

    当Flags字段中指定CF_PRINTERFONTS时,它是打印机的DC句柄。

    lpLogFont

    指向一个LOGFONT结构体的指针

    iPointSize

    选择的字体大小,单位是1/0磅

    Flags

    CF_INITTOLOGFONTSTRUCT:根据ChooseFont函数中的LOGFONT初始化。

    CF_TTONLY:只使用TrueType字体

    CF_FIXEDPITCHONLY:只显示等宽字体

    CF_SCRIPTSONLY:非符号字体

    CF_SCREENFONTS:屏幕字体

    CF_PRINTERFONTS:打印机字体

    CF_BOTH:屏幕字体和打印机字体

    CF_EFFECTS:对话框中显示“效果”复选框,包含下划线和删除复选框,还允许选择文本颜色。

    CF_LIMITSIZE:显示字体的尺寸限于nSizeMin和nSizeMax之间。

    CF_NOSTYLESEL:不显示“字形”组合列表框

    CF_NOSIZESEL:不显示“大小”组合列表框

    rgbColors

    选择的字体颜色,如果Flags字段的CF_EFFECTS被设置,对话框将根据这个数值初始化“颜色”下拉列表框 。另外,函数返回时在这里返回用户选择的字体颜色。

    hInstance

    lpszStyle

    nFontType

    返回用户选择的字体是属于哪一类的,可能返回值有:BOLD_FONTTYPE、ITALIC_FONTTYPE、PRINTER_FONTTYPE、REGULAR_FONTTYPE、SCREEN_FONTTYPE等。

    nSizeMin

    设置用户可选择的字体最小的磅值(需指定CF_LIMITSIZE)

    nSizeMax

    设置用户可选择的字体最大的磅值(需指定CF_LIMITSIZE)

    (2)ChooseFont函数

      ①该函数会根据像素点的大小,使用逻辑英寸为单位来计算lfHeight字段。也就是根据LOGPIXELSY来磅值转化为lfHeight。如当LOGPIXELSY=96时,需要字体的高度为1英寸,则应在“字体”对话框中选择72磅的Times Roman字体。这里ChooseFont函数返回时,LOGFONT结构的lfHeight=-96(注意,有一个负号)

      ②LONGFONT中的lfHeight使用的是逻辑坐标,所以更改映射模式时,这里的值需相应的变化。

      ③ChooseFont函数设置的LOGFONT的lfHeight字段总是使用像素为单位的,且它仅适合视频显示(参考①的说明)

      ④CHOOSEFONT字段的iPointSize表示字体的磅值的大小,以1/10磅的为单位,无论映射模式怎么改变,这个值都不会变。可以将该字段转化为逻辑尺寸供fHeight使用。

    【ChooseFont程序】

    /*------------------------------------------------------------
    CHOOSEFONT.C -- ChooseFont Demo
    (c) Charles Petzold, 1998
    ------------------------------------------------------------*/
    #include <windows.h>
    #include "resource.h"
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                       PSTR szCmdLine, int iCmdShow)
    {
        static TCHAR szAppName[] = TEXT("ChosFont");
        HWND         hwnd;
        MSG          msg;
        WNDCLASSEX     wndclass;
        wndclass.style = CS_HREDRAW | CS_VREDRAW;
        wndclass.cbSize = sizeof(WNDCLASSEX);
        wndclass.lpfnWndProc = WndProc;
        wndclass.cbClsExtra = 0;
        wndclass.cbWndExtra = 0;
        wndclass.hInstance = hInstance;
        wndclass.hIcon = LoadIcon(hInstance, szAppName);
        wndclass.hIconSm = LoadIcon(hInstance, szAppName);
        wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
        wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
        wndclass.lpszMenuName = szAppName;
        wndclass.lpszClassName = szAppName;
        if (!RegisterClassEx(&wndclass))
        {
            MessageBox(NULL, TEXT("This program requires Windows NT!"),
                       szAppName, MB_ICONERROR);
            return 0;
        }
    
        hwnd = CreateWindow(szAppName,                  // window class name
                            TEXT("ChooseFont"), // window caption
                            WS_OVERLAPPEDWINDOW,        // window style
                            CW_USEDEFAULT,              // initial x position
                            CW_USEDEFAULT,              // initial y position
                            CW_USEDEFAULT,              // initial x size
                            CW_USEDEFAULT,              // initial y size
                            NULL,                       // parent window handle
                            NULL,                       // window menu handle
                            hInstance,                  // program instance handle
                            NULL);                     // creation parameters
    
        ShowWindow(hwnd, iCmdShow);
        UpdateWindow(hwnd);
    
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        return msg.wParam;
    }
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        static TCHAR      szText[] = TEXT("x41x42x43x44x45 ")
            TEXT("x61x62x63x64x65 ")
            TEXT("xC0xC1xC2xC3xC4xC5 ")
            TEXT("xE0xE1xE2xE3xE4xE5 ")
    #ifdef UNICODE
            TEXT("x0390x0391x0392x0393x0394x0395 ")
            TEXT("x03B0x03B1x03B2x03B3x03B4x03B5 ")
            TEXT("x0410x0411x0412x0413x0414x0415 ")
            TEXT("x0430x0431x0432x0433x0434x0435 ")
            TEXT("x5000x5001x5002x5003x5004")
    #endif
            ;
        static CHOOSEFONT cf;
        static int cyChar;
        static LOGFONT lf;
        TEXTMETRIC tm;
        HDC         hdc;
        PAINTSTRUCT ps;
        int y;
        TCHAR szBuffer[64];
        switch (message)
        {
        case WM_CREATE:
            //获得文字的高度
            cyChar = HIWORD(GetDialogBaseUnits());
            //初始化LOGFONT结构体
            GetObject(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), &lf);
            //初始化CHOOSEFONT结构体
            memset(&lf, 0, sizeof(CHOOSEFONT));
            cf.lStructSize = sizeof(CHOOSEFONT);
            cf.hwndOwner = hwnd;
            cf.hDC = NULL;
            cf.lpLogFont = &lf;
            cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_EFFECTS;
            return 0;
        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
            case IDM_FONT:
                if (ChooseFont(&cf))
                    InvalidateRect(hwnd, NULL, TRUE);
                return 0;
            }
            break;
    
        case WM_PAINT:
            hdc = BeginPaint(hwnd, &ps);
    
            //用所选择的字体显示文字示例样本
            SelectObject(hdc, CreateFontIndirect(&lf));
            GetTextMetrics(hdc, &tm);
            SetTextColor(hdc, cf.rgbColors);
            TextOut(hdc, 0, y = tm.tmExternalLeading, szText, lstrlen(szText));
            DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
            //用系统字体显示LOGFONT结构体的各字段信息
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfHeight = %i"), lf.lfHeight));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfWidth = %i"), lf.lfWidth));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfEscapement = %i"), lf.lfEscapement));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfOrientation = %i"), lf.lfOrientation));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfWeight= %i"), lf.lfWeight));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfItalic = %i"), lf.lfItalic));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfUnderline = %i"), lf.lfUnderline));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfStrikeOut = %i"), lf.lfStrikeOut));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfCharSet = %i"), lf.lfCharSet));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfOutPrecision = %i"), lf.lfOutPrecision));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfClipPrecision = %i"), lf.lfClipPrecision));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfQuality = %i"), lf.lfQuality));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfPitchAndFamily = 0x%02X"), lf.lfPitchAndFamily));
            TextOut(hdc, 0, y += tm.tmHeight, szBuffer,
                    wsprintf(szBuffer, TEXT("lfFaceName = %s"), lf.lfFaceName));
            EndPaint(hwnd, &ps);
            return 0;
    
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
        }
        return DefWindowProc(hwnd, message, wParam, lParam);
    }

    //resource.h

    //{{NO_DEPENDENCIES}}
    // Microsoft Visual C++ 生成的包含文件。
    // 供 ChooseFont.rc 使用
    //
    #define IDM_FONT                        40002
    // Next default values for new objects
    // 
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_NEXT_RESOURCE_VALUE        102
    #define _APS_NEXT_COMMAND_VALUE         40003
    #define _APS_NEXT_CONTROL_VALUE         1001
    #define _APS_NEXT_SYMED_VALUE           101
    #endif
    #endif

    //ChooseFont.rc

    // Microsoft Visual C++ generated resource script.
    //
    #include "resource.h"
    #define APSTUDIO_READONLY_SYMBOLS
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 2 resource.
    //
    #include "winres.h"
    /////////////////////////////////////////////////////////////////////////////
    #undef APSTUDIO_READONLY_SYMBOLS
    /////////////////////////////////////////////////////////////////////////////
    // 中文(简体,中国) resources
    #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
    LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
    #ifdef APSTUDIO_INVOKED
    /////////////////////////////////////////////////////////////////////////////
    //
    // TEXTINCLUDE
    //
    1 TEXTINCLUDE
    BEGIN
    "resource.h"
    END
    2 TEXTINCLUDE
    BEGIN
    "#include ""winres.h""
    "
    ""
    END
    3 TEXTINCLUDE
    BEGIN
    "
    "
    ""
    END
    #endif    // APSTUDIO_INVOKED
    /////////////////////////////////////////////////////////////////////////////
    //
    // Menu
    //
    CHOSFONT MENU
    BEGIN
    MENUITEM "&Font!", IDM_FONT
    END
    #endif    // 中文(简体,中国) resources
    /////////////////////////////////////////////////////////////////////////////
    #ifndef APSTUDIO_INVOKED
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 3 resource.
    //
    /////////////////////////////////////////////////////////////////////////////
    #endif    // not APSTUDIO_INVOKED

    【UniChars程序】

    /*------------------------------------------------------------
    UNICHARS.C -- Displays 16-bit character codes
    (c) Charles Petzold, 1998
    ------------------------------------------------------------*/
    #include <windows.h>
    #include "resource.h"
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                       PSTR szCmdLine, int iCmdShow)
    {
        static TCHAR szAppName[] = TEXT("UniChars");
        HWND         hwnd;
        MSG          msg;
        WNDCLASSEX     wndclass;
        wndclass.style = CS_HREDRAW | CS_VREDRAW;
        wndclass.cbSize = sizeof(WNDCLASSEX);
        wndclass.lpfnWndProc = WndProc;
        wndclass.cbClsExtra = 0;
        wndclass.cbWndExtra = 0;
        wndclass.hInstance = hInstance;
        wndclass.hIcon = LoadIcon(hInstance, szAppName);
        wndclass.hIconSm = LoadIcon(hInstance, szAppName);
        wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
        wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
        wndclass.lpszMenuName = szAppName;
        wndclass.lpszClassName = szAppName;
        if (!RegisterClassEx(&wndclass))
        {
            MessageBox(NULL, TEXT("This program requires Windows NT!"),
                       szAppName, MB_ICONERROR);
            return 0;
        }
    
        hwnd = CreateWindow(szAppName,                  // window class name
                            TEXT("Unicode Characters"), // window caption
                            WS_OVERLAPPEDWINDOW | WS_VSCROLL,        // window style
                            CW_USEDEFAULT,              // initial x position
                            CW_USEDEFAULT,              // initial y position
                            CW_USEDEFAULT,              // initial x size
                            CW_USEDEFAULT,              // initial y size
                            NULL,                       // parent window handle
                            NULL,                       // window menu handle
                            hInstance,                  // program instance handle
                            NULL);                     // creation parameters
    
        ShowWindow(hwnd, iCmdShow);
        UpdateWindow(hwnd);
    
        while (GetMessage(&msg, NULL, 0, 0))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        return msg.wParam;
    }
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        HDC         hdc;
        PAINTSTRUCT ps;
        static CHOOSEFONT cf;
        static LOGFONT lf;
        TEXTMETRIC tm;
        static int iPage;
        int cxChar, cyChar, cxLabels, i, x, y;
        TCHAR szBuffer[8];
        SIZE size;
        WCHAR ch;
        switch (message)
        {
        case WM_CREATE:
    
            //初始化LOGFONT结构体
            hdc = GetDC(hwnd);
            lf.lfHeight = -GetDeviceCaps(hdc, LOGPIXELSY) / 6;  //96/6=12像素
            lstrcpy(lf.lfFaceName, TEXT("宋体"));
            ReleaseDC(hwnd, hdc);
            //初始化CHOOSEFONT结构体
            memset(&lf, 0, sizeof(CHOOSEFONT));  //也可以不设置,因为static属性默认各字段为0
            cf.lStructSize = sizeof(CHOOSEFONT);
            cf.hwndOwner = hwnd;
            cf.hDC = NULL;
            cf.lpLogFont = &lf;
            cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS | CF_EFFECTS;
            SetScrollRange(hwnd, SB_VERT, 0, 255, FALSE);
            SetScrollPos(hwnd, SB_VERT, iPage, TRUE);
            return 0;
        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
            case IDM_FONT:
                if (ChooseFont(&cf))
                    InvalidateRect(hwnd, NULL, TRUE);
                return 0;
            }
            break;
        case WM_VSCROLL:
            switch (LOWORD(wParam))
            {
            case SB_LINEUP:        iPage -= 1;     break;
            case SB_LINEDOWN:      iPage += 1;     break;
            case SB_PAGEUP:        iPage -= 16;    break;
            case SB_PAGEDOWN:      iPage += 16;    break;
            case SB_THUMBPOSITION: iPage = HIWORD(wParam); break;
            default:
                return 0;
            }
    
            iPage = max(0, min(iPage, 255));
            SetScrollPos(hwnd, SB_VERT, iPage, TRUE);
            InvalidateRect(hwnd, NULL, TRUE);
            return 0;
        case WM_PAINT:
            hdc = BeginPaint(hwnd, &ps);
    
            SelectObject(hdc, CreateFontIndirect(&lf));
            GetTextMetrics(hdc, &tm);
            cxChar = tm.tmMaxCharWidth;  //字符的最大宽度
            cyChar = tm.tmHeight + tm.tmExternalLeading;
            cxLabels = 0;
            //计算列标题最大的宽度
            for (i = 0; i < 16; i++)
            {
                wsprintf(szBuffer, TEXT(" 000%1X: "), i); //共7个字符
                GetTextExtentPoint32(hdc, szBuffer, 7, &size);
                cxLabels = max(cxLabels, size.cx);
            }
            for (y = 0; y < 16; y++)
            {
                //列标题
                wsprintf(szBuffer, TEXT(" %03X_: "), 16 * iPage + y);
                TextOut(hdc, 0, y*cyChar, szBuffer, 7);
                for (x = 0; x < 16; x++)
                {
                    ch = (WCHAR)(256 * iPage + 16 * y + x); //每页中的数据
                    //x*cxChar + cxLabels:加cxLabels,就是从列标题后开始输出
                    TextOutW(hdc, x*cxChar + cxLabels, y*cyChar, &ch, 1); //用宽字符版的TextOut
                }
            }
            DeleteObject(SelectObject(hdc, GetStockObject(SYSTEM_FONT)));
            EndPaint(hwnd, &ps);
            return 0;
    
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
        }
        return DefWindowProc(hwnd, message, wParam, lParam);
    }

    //resource.h

    //{{NO_DEPENDENCIES}}
    // Microsoft Visual C++ 生成的包含文件。
    // 供 UniChars.rc 使用
    //
    #define IDM_FONT                        40002
    // Next default values for new objects
    // 
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_NEXT_RESOURCE_VALUE        102
    #define _APS_NEXT_COMMAND_VALUE         40003
    #define _APS_NEXT_CONTROL_VALUE         1001
    #define _APS_NEXT_SYMED_VALUE           101
    #endif
    #endif

    //UniChars.rc

    // Microsoft Visual C++ generated resource script.
    //
    #include "resource.h"
    #define APSTUDIO_READONLY_SYMBOLS
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 2 resource.
    //
    #include "winres.h"
    /////////////////////////////////////////////////////////////////////////////
    #undef APSTUDIO_READONLY_SYMBOLS
    /////////////////////////////////////////////////////////////////////////////
    // 中文(简体,中国) resources
    #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
    LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
    #ifdef APSTUDIO_INVOKED
    /////////////////////////////////////////////////////////////////////////////
    //
    // TEXTINCLUDE
    //
    1 TEXTINCLUDE
    BEGIN
    "resource.h"
    END
    2 TEXTINCLUDE
    BEGIN
    "#include ""winres.h""
    "
    ""
    END
    3 TEXTINCLUDE
    BEGIN
    "
    "
    ""
    END
    #endif    // APSTUDIO_INVOKED
    /////////////////////////////////////////////////////////////////////////////
    //
    // Menu
    //
    UNICHARS MENU
    BEGIN
    MENUITEM "&Font!", IDM_FONT
    END
    #endif    // 中文(简体,中国) resources
    /////////////////////////////////////////////////////////////////////////////
    #ifndef APSTUDIO_INVOKED
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 3 resource.
    //
    /////////////////////////////////////////////////////////////////////////////
    #endif    // not APSTUDIO_INVOKED
  • 相关阅读:
    软件架构——”淘宝网”质量属性研究
    漫谈架构——读后感
    问题账户需求分析
    关于《软件需求分析》需要掌握哪些必要的内容的总结与思考------读后感
    人月神话阅读笔记4
    **系统项目目标文档
    人月神话阅读笔记3
    人月神话阅读笔记2
    人月神话阅读笔记1
    问题账户需求分析
  • 原文地址:https://www.cnblogs.com/5iedu/p/4701494.html
Copyright © 2011-2022 走看看