ho fatto un po' di copia e incolla da varie fonti percui il codice non è in ordine, però questo serve a disegnare un rettangolo che si allarga a partire dal centro della schermo con sfondo nero e bordo verde.
La barra degli strumenti potrebbe rimanere offesa...
codice:
Private Const HORZRES As Long = 8 'Horizontal width in pixels
Private Const VERTRES As Long = 10 'Vertical height in pixels
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, lpPoint As POINTAPI) As Long
Private Declare Function SetActiveWindow Lib "user32.dll" (ByVal hwnd As Long) As Long
Private Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hdc As Long, _
ByVal nIndex As Long) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Function GetHSize()
GetHSize = GetDeviceCaps(GetDC(GetDesktopWindow), HORZRES)
End Function
Public Function GetVSize()
GetVSize = GetDeviceCaps(GetDC(GetDesktopWindow), VERTRES)
End Function
Public Sub Giochino()
Dim HWndP As Long
Dim HDCP As Long
Dim DesktopHWnd As Long
Dim i As Long
Dim point As POINTAPI
Dim VSize As Long, HSize As Long
Dim hHBr As Long, hRPen As Long
HDCP = GetWindowDC(GetDesktopWindow)
'Create a new brush
hHBr = CreateSolidBrush(vbBlack)
'Create a new pen
hRPen = CreatePen(PS_SOLID, 5, vbGreen)
'Select our pen into the form's device context and delete the old pen
DeleteObject SelectObject(HDCP, hRPen)
DeleteObject SelectObject(HDCP, hHBr)
For i = Schermo.GetVSize / 2 To 1 Step -1
Rectangle HDCP, i + 4, i + 4, Schermo.GetHSize - i + 4, Schermo.GetVSize - i + 4
Sleep (2)
Next i
DeleteObject hRPen
DeleteObject hHBr
end Sub
Lo usate a vostro rischio e pericolo...