| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1175 人关注过本帖
标题:各位前輩好!!該如何在VS2008中調用GetWindowRect
只看楼主 加入收藏
uirty
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-12-4
结帖率:100%
收藏
已结贴  问题点数:0 回复次数:2 
各位前輩好!!該如何在VS2008中調用GetWindowRect
2008中並無報告出錯 ,但是程式按鍵執行就當.....請各位前輩指導T_T.
程序代码:
Public Class Form1
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    Private Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Integer
    Private Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, ByVal lpRect As RECT) As Integer
    Private Structure RECT
        Public Left As Integer
        Public Top As Integer
        Public Right As Integer
        Public Bottom As Integer
    End Structure
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim windoh As Integer
        Dim windoxy As RECT
        Dim windoxd As Integer
        windoh = FindWindow(vbNullString, "新增文字文件 (6).txt - 記事本")

        If windoh = 0 Then
            MsgBox("無法獲取窗口")
            Threading.Thread.Sleep(100) ' 暫停1秒
            SetCursorPos(0, 0) ' 將滑鼠位置設定為0, 0
        End If

        windoxd = GetWindowRect(windoh, windoxy)

        TextBoxX.Text = windoxy.Top
        TextBoxY.Text = windoxy.Left
    End Sub
End Class

 
搜索更多相关主题的帖子: 如何 
2010-12-04 02:51
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:20 
程序代码:
Public Class Form1
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    Private Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Integer
    Private Declare Function GetWindowRect Lib "user32 " Alias "GetWindowRect" (ByVal hwnd As Integer, ByRef lpRect As RECT) As Boolean
    Private Structure RECT
        Public Left As Integer
        Public Top As Integer
        Public Right As Integer
        Public Bottom As Integer
    End Structure
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim windoh As Integer
        Dim windoxy As New RECT
        Dim windoxd As Long
        windoh = FindWindow(vbNullString, "新增文字文件 (6).txt - 记事本")

        If windoh = 0 Then
            MsgBox("無法獲取窗口")
            Threading.Thread.Sleep(100) ' 暫停1秒
            SetCursorPos(0, 0) ' 將滑鼠位置設定為0, 0
        End If

        windoxd = GetWindowRect(windoh, windoxy)

        TextBoxX.Text = windoxy.Top
        TextBoxY.Text = windoxy.Left
    End Sub
End Class
注意GetWindowRect的声明
收到的鲜花
  • uirty2010-12-04 23:33 送鲜花  3朵   附言:好文章

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2010-12-04 16:15
uirty
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-12-4
收藏
得分:0 
回复 2楼 不说也罢
感謝前輩的指導 我的腦亂了
2010-12-04 23:35
快速回复:各位前輩好!!該如何在VS2008中調用GetWindowRect
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021513 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved