学习WM_PAINT的一点记录

一、传递WM_PAINT消息的时机
当一个窗口被移动或改变大小或被其他窗口以及事件以一定的图形方式变暗时,该窗口的用户区的一部分

或全部都需要刷新时.

二、BeginPaint函数返回值ps(PAINTSTRUCT)的结构
typedef struct tagPAINTSTRUCT
{
    HDC hdc; //graphics device context
    BOOL fErase; //if TRUE then you must draw background
    RECT rcPaint; //the RECT containing invalid region
    BOOL fRestore; //internal
    BOOL fIncUpdate; //internal
    BYTE rgbreserved[32];//internal
}PAINTSTRUCT;

三、调用GetDc()--ReleaseDc()时
首先,它们不像BeginPaint()--EndPaint()一样会通知Windows窗口内容已经恢复,因此必须使用专用函数

ValidateRect()来通知Windows已经恢复了该窗口
其次,调用GetDc()--ReleaseDc()的作用在于可以重绘整个窗口区域,而BeginPaint()--EndPaint()只是重

绘无效区域

四、关于窗口坐标的问题
由于窗口可以任意移动,一个窗口都有两套坐标;windows坐标和用户坐标。Windows坐标相对于屏幕,而用

户坐标相对于该窗口的左上角,如GetClientRect()获取的就是用户矩形区域的坐标

五、如何手动使一个窗口无效
Case WM_PAINT:
{
    InvalidateRect(hwnd,NULL,FALSE);

    hdc = BeginPaint(hwnd,&ps);

    EndPaint(hwnd,&ps);

    return(0);
}

五、基本文本打印
BOOL TextOut(HDC hdc,    //dc句柄
             int nXStart,//x-coordinate of starting position
             int nYStart,//x-coordinate of starting position
             LPCTSTP lpString,//..
             int cbString)//..

int DrawText(HDC hdc,    //dc句柄
             LPCTSTP lpString,//..pointer to string to draw
             int nCount,      //string length
             LPRECT lpRect,   //ptr to bounding Rect
             UINT uFormat)    //text-drawing flags 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值