Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function FillRect Lib "user32" (ByVal hdc As Long, _
lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function GetStockObject Lib "gdi32" _
(ByVal nIndex As Long) As Long
Private Sub cmdDemo_Click()
Dim nhDC As Long
Dim nRECT As RECT
Const SM_CYFRAME = 33
Const SM_CXFRAME = 32
Const SM_CYSIZEFRAME = SM_CYFRAME
Const SM_CXSIZEFRAME = SM_CXFRAME
Const SM_CXICON = 11
Const SM_CYCAPTION = 4
Const WHITE_BRUSH = 0
'/첫번째 블럭의 위치와 크기를 구한다.
nRECT.Top = GetSystemMetrics(SM_CYSIZEFRAME)
nRECT.Left = GetSystemMetrics(SM_CXSIZEFRAME)
nRECT.Left = nRECT.Left + GetSystemMetrics(SM_CXICON) + 100
nRECT.Bottom = nRECT.Top + GetSystemMetrics(SM_CYCAPTION) - 1
nRECT.Right = nRECT.Left + 5
'/메뉴, 타이틀바, 스크롤바를 포함한 전체 윈도우에 대한 DC를 구한다.
nhDC = GetWindowDC(Me.hwnd)
'/타이틀바에 15블럭을 칠한다.
For I = 1 To 15
FillRect nhDC, nRECT, GetStockObject(WHITE_BRUSH)
nRECT.Left = nRECT.Left + 10
nRECT.Right = nRECT.Right + 10
Next I
'/ DC해제
ReleaseDC Me.hwnd, nhDC
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
End Sub