I am trying to use GetWindowRect or GetWindowPlacement to find the coordinates of a window that I have the handle for, but every time I try to use GetWindowRect, I get this error:
Here is the code I am using:Code:An unhandled exception of type 'System.NullReferenceException' occurred in testapplication.exe Additional information: Object reference not set to an instance of an object.
VB Code:
Dim r As New RECT GetWindowRect(hwnd, r) MsgBox(r.Left)
hwnd is the window handle, the API calls are all declared public in a module. Here is my converted RECT structure:
VB Code:
Public Structure RECT Dim Left As Integer Dim Top As Integer Dim Right As Integer Dim Bottom As Integer End Structure
Anyone see why it would give me a null exception error? I know for sure that the window handle is valid because I can use SetForegroundWindow on the same variable and it brings the application to the front of the screen.
Thanks for any help/ideas you can give.![]()




Reply With Quote