如果是的话用API Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
如果是的话用API Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long ================= 我正是这个意思,可是我不会用这个ClientToScreen,可否给小弟一个例子?
'This project needs 2 Buttons 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 LongDim P As POINTAPI Private Sub Form_Load() 'KPD-Team 1998 'URL: http://www.allapi.net/ 'E-Mail: [email protected] Command1.Caption = "Screen Middle" Command2.Caption = "Form Middle" 'API uses pixels Me.ScaleMode = vbPixels End Sub Private Sub Command1_Click() 'Get information about the screen's width P.x = GetDeviceCaps(Form1.hdc, 8) / 2 'Get information about the screen's height P.y = GetDeviceCaps(Form1.hdc, 10) / 2 'Set the mouse cursor to the middle of the screen ret& = SetCursorPos(P.x, P.y) End Sub Private Sub Command2_Click() P.x = 0 P.y = 0 'Get information about the form's left and top ret& = ClientToScreen&(Form1.hwnd, P) P.x = P.x + Me.ScaleWidth / 2 P.y = P.y + Me.ScaleHeight / 2 'Set the cursor to the middle of the form ret& = SetCursorPos&(P.x, P.y) End Sub
Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
=================
我正是这个意思,可是我不会用这个ClientToScreen,可否给小弟一个例子?
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 LongDim P As POINTAPI
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: [email protected] Command1.Caption = "Screen Middle"
Command2.Caption = "Form Middle"
'API uses pixels
Me.ScaleMode = vbPixels
End Sub
Private Sub Command1_Click()
'Get information about the screen's width
P.x = GetDeviceCaps(Form1.hdc, 8) / 2
'Get information about the screen's height
P.y = GetDeviceCaps(Form1.hdc, 10) / 2
'Set the mouse cursor to the middle of the screen
ret& = SetCursorPos(P.x, P.y)
End Sub
Private Sub Command2_Click()
P.x = 0
P.y = 0
'Get information about the form's left and top
ret& = ClientToScreen&(Form1.hwnd, P)
P.x = P.x + Me.ScaleWidth / 2
P.y = P.y + Me.ScaleHeight / 2
'Set the cursor to the middle of the form
ret& = SetCursorPos&(P.x, P.y)
End Sub