各位前輩好!!該如何在VS2008中調用GetWindowRect
2008中並無報告出錯 ,但是程式按鍵執行就當.....請各位前輩指導T_T.![](zzz/editor/img/code.gif)
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