首页 > Windows开发 > 详细

《windows程序设计》文本输出(02)

时间:2018-10-05 13:14:26      阅读:168      评论:0      收藏:0      [点我收藏+]

技术分享图片

获取设备环境句柄:

方法一:
hdc  = BeginPaint(hwnd, &ps);
    //使用GDI函数
EndPaint(hwnd, &ps);

方法二:
hdc = GetDc(hwnd);
    //使用GDI函数
ReleaseDc(hwnd, hdc)

 消息循环代码如下:

 

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        case WM_PAINT:
            hdc = BeginPaint(hwnd, &ps);
            TextOut(hdc,0,0,"hello world",11);
            EndPaint(hwnd, &ps);
            break;
        default:                      /* for messages that we don‘t deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}

 

 

 

 

 

 

 

《windows程序设计》文本输出(02)

原文:https://www.cnblogs.com/YiShen/p/9744565.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!