一、传递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