一、傳遞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