Private Sub Timer1_Timer()
DoEvents
' Grab the middle pixels.
GrabPixels 50, 50
End Sub
Private Sub GrabPixels(ByVal area_wid As Long, ByVal _
area_hgt As Long)
Dim desktop_rect As RECT
Dim desktop_win As Long
Dim desktop_dc As Long
Dim desktop_wid As Long
Dim desktop_hgt As Long
' Get the desktop size in pixels.
desktop_win = GetDesktopWindow()
desktop_dc = GetDC(desktop_win)
GetWindowRect desktop_win, desktop_rect
desktop_wid = desktop_rect.Right
desktop_hgt = desktop_rect.Bottom
' Size the form.
Width = ScaleX(area_wid, vbPixels, vbTwips) + Width - _
ScaleWidth
Height = ScaleY(area_hgt, vbPixels, vbTwips) + Height - _
ScaleHeight
' Copy the middle of the desktop's image.
StretchBlt _
hdc, 0, 0, area_wid, area_hgt, _
desktop_dc, _
(desktop_wid - area_wid) \ 2, _
(desktop_hgt - area_hgt) \ 2, _
area_wid, area_hgt, SRCCOPY
Picture = Image
' Release the desktop's device context.
ReleaseDC desktop_win, desktop_dc
End Sub
|