GetWindowRect returns 0,0,0,0

Joined
Jul 8, 2010
Messages
2
Reaction score
0
How hard can it be?
Hmmm - seems I'm doing something wrong with GETWINDOWRECT.
I've simplified as much as possible, but still only get 0,0,0,0 back in my "rect"
Any one seen this?
Running Windows 7, VB 2008


FORM:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim wRect, cRect As RECT
Myhandle = Me.Handle
GetWindowRect(Myhandle, wRect)
MsgBox("WINDOW: " & wRect.Top.ToString & " - " & wRect.Left.ToString & " - " & wRect.Bottom.ToString & " - " & wRect.Right.ToString)
GetClientRect(Myhandle, cRect)
MsgBox("CLIENT WINDOW: " & cRect.Top.ToString & " - " & cRect.Left.ToString & " - " & cRect.Bottom.ToString & " - " & cRect.Right.ToString)

End Sub
--------------
MODULE:
Declare Auto Function GetWindowRect Lib "user32" (ByVal hWnd As IntPtr, ByVal lpRect As RECT) As Integer
Declare Auto Function GetClientRect Lib "user32" (ByVal hwnd As IntPtr, ByVal lpRect As RECT) As Integer
Public Structure RECT
Dim Left As Integer
Dim Top As Integer
Dim Right As Integer
Dim Bottom As Integer
End Structure

Public MyPROCESS As New Process
Public Myhandle As IntPtr
 
Joined
Jul 8, 2010
Messages
2
Reaction score
0
Oh fudge! How stupid of me!

I used ByVal instead of ByRef for the RECT parm.
DUH!
- Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top