強制和防止窗口重畫
導(dǎo)讀:這個例子告訴你如何強制窗口的一部分重畫。有時這是必須的,上學吧提示當你試驗自己重畫控件的技術(shù),或者已經(jīng)使用了LockWindowUpdate這個API函數(shù)以阻止控件重畫時(參見“防止一個窗口重畫”)。
新建一個項目,添加一個module,然后粘貼下列代碼:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT, ByVal bErase As Long) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
Public Sub RepaintWindow(ByRef objThis As Object, Optional ByVal bClientAreaOnly As Boolean = True)
Dim tR As RECT
Dim tP As POINTAPI
If (bClientAreaOnly) Then
GetClientRect objThis.hWnd, tR
Else
相關(guān)推薦:北京 | 天津 | 上海 | 江蘇 | 山東 |
安徽 | 浙江 | 江西 | 福建 | 深圳 |
廣東 | 河北 | 湖南 | 廣西 | 河南 |
海南 | 湖北 | 四川 | 重慶 | 云南 |
貴州 | 西藏 | 新疆 | 陜西 | 山西 |
寧夏 | 甘肅 | 青海 | 遼寧 | 吉林 |
黑龍江 | 內(nèi)蒙古 |