| Ce projet nécessite 2 Boutons Private
Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long,
lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As
Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal
nIndex As Long) As Long
Dim P As POINTAPI
Private Sub Form_Load()
'VbAndJava 1999/2000
'Guerrault Yonni
'E-Mail : Yonni4@iFrance.com
Command1.Caption = "Curseur au milieu de l' écran"
Command2.Caption = "Curseur au milieu de la Form"
Me.ScaleMode = vbPixels
End Sub
Private Sub Command1_Click()
P.x = GetDeviceCaps(Form1.hdc, 8) / 2
P.y = GetDeviceCaps(Form1.hdc, 10) / 2
ret& = SetCursorPos(P.x, P.y)
End Sub
Private Sub Command2_Click()
P.x = 0
P.y = 0
ret& = ClientToScreen&(Form1.hwnd, P)
P.x = P.x + Me.ScaleWidth / 2
P.y = P.y + Me.ScaleHeight / 2
ret& = SetCursorPos&(P.x, P.y)
End Sub |