Consider the following code:
LPRECT lpRect;
GetWindowRect(hwnd, lpRect);
I don't know how to get information from lpRect
; please advise.
LPRECT is a derived type which says it is a pointer to RECT . Having a variable of this type, you declared a pointer to nothing, to invalid memory address (the pointer variable is left uninitialized). Your code would expectedly crash the app.
Retrieves the coordinates of a window's client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner are (0,0).
What you wrote is wrong. The Windows API uses a hideous variable and type naming convention. LPRECT
means "Long Pointer to Rect", which on your usual architecture is just a RECT*
. What you wrote is some uninitialized pointer variable, pointing at some arbitrary location (if you're unlucky something that when modified will crash your program).
This is what you actually require:
RECT rect;
GetWindowRect(hwnd, &rect);
RECT itself is a structure
typedef struct _RECT {
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;
You can get the coordinates of the window :
lpRect->left
lpRect->right
lpRect->top
lpRect->bottom
More information here : http://msdn.microsoft.com/en-us/library/windows/desktop/dd162897(v=vs.85).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With