ClientToScreen用来判断窗口内以客户区坐标表示的一个点的屏幕坐标
声明:
Declare Function ClientToScreen Lib "user32" Alias "ClientToScreen" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long参数:
Long,非零表示成功,零表示失败hwnd ----------- Long,判断客户区坐标时那个窗口的句柄
lpPoint -------- POINTAPI,用hwnd窗口的客户区坐标表示的点,这个参数会包含屏幕坐标系统中相同的点实例:
'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" Alias "ClientToScreen" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long参数:
Long,非零表示成功,零表示失败hwnd ----------- Long,判断客户区坐标时那个窗口的句柄
lpPoint -------- POINTAPI,用hwnd窗口的客户区坐标表示的点,这个参数会包含屏幕坐标系统中相同的点实例:
'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
解决方案 »
- VB如何下载有密码的FTP服务器上的文件(密码已知)
- MSFlexGrid放置时间控件
- 求ROT应用示例
- CommonDialog中的.Filename是得到绝对路径,但是我想得到相对路径应该怎么弄?谢谢!
- 有没有方法能够把我编写的VB程序自动的转换成网页.另外网页与程序之间传送数据有没有好的方法.
- 发现新世纪ERP源代码可以免费下载了!!
- asp导出execl合并上下两行代码怎么写
- 有用过codehelp的吗?请教CHCoder!
- XP 与 win7
- 各位大虾请问textTospeech这个控件在何处,如何使用?(绝对给分)
- 创建相对路径的问题(急急急)
- 多个相同的DCOM客户程序同时访问同一个ActiveX EXE,客户端之间如何相互通讯?(限于DCOM)
ClientToScreen