以文本方式查看主题
- Foxtable(狐表) (http://foxtable.net/bbs/index.asp)
-- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2)
---- [求助]请问这段代码怎么转到狐表里面? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=143097)
|
-- 作者:zto001
-- 发布时间:2019/11/13 15:04:00
-- [求助]请问这段代码怎么转到狐表里面?
Public Class Form1 Private Declare Auto Function GetWindowRect Lib "user32" (ByVal hwnd As IntPtr, ByRef lpRect As RECT) As Long Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Public Structure RECT Public left As Int32 Public top As Int32 Public right As Int32 Public bottom As Int32 End Structure Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim p1 As RECT Dim hwnd As IntPtr = FindWindow(Nothing, "无标题 - 记事本") If hwnd <> IntPtr.Zero Then GetWindowRect(Me.Handle, p1) MsgBox(p1.right) \'获取到left ,top ,right ,bottom Else MsgBox("未找到窗口") End If
End Sub End Class
[求助]请问这段代码怎么转到狐表里面?来查找外部窗口位置?
[此贴子已经被作者于2019/11/13 15:04:58编辑过]
|
-- 作者:有点蓝
-- 发布时间:2019/11/13 15:13:00
--
全局代码 Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As IntPtr, ByRef lpRect As RECT) As Long Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Public Structure RECT Public left As Int32 Public top As Int32 Public right As Int32 Public bottom As Int32 End Structure Public Sub Button1_Click() Dim p1 As RECT Dim hwnd As IntPtr = FindWindow(Nothing, "无标题 - 记事本") If hwnd <> IntPtr.Zero Then GetWindowRect(Me.Handle, p1) MsgBox(p1.right) \'获取到left ,top ,right ,bottom Else MsgBox("未找到窗口") End If
End Sub
调用 Button1_Click()
|
-- 作者:zto001
-- 发布时间:2019/11/13 17:56:00
--
GetWindowRect(Me.Handle, p1)这里出错,me在模块中无效
|
-- 作者:程兴刚
-- 发布时间:2019/11/13 18:45:00
--
说明您贴出的代码不全
|
-- 作者:zto001
-- 发布时间:2019/11/14 8:53:00
--
vb能获取到 此主题相关图片如下:qq图片20191114085239.png
|
-- 作者:有点蓝
-- 发布时间:2019/11/14 9:46:00
--
GetWindowRect(Me.Handle, p1)
改为
GetWindowRect(hwnd , p1)
|