How to use GetWindowRect

Consider the following code:

LPRECT lpRect; lpRect = malloc(sizeof(LPRECT)); GetWindowRect(hwnd, lpRect); 

I do not know how to get information from lpRect ; please inform.

+4
source share
2 answers

What you wrote is wrong. The Windows API uses a nasty convention of naming and naming types. LPRECT means "Long Pointer to Rect", which in your usual architecture is just RECT* . What you wrote is some uninitialized pointer variable pointing to some arbitrary location (if you are unlucky that changing your program will crash).

This is what you really need:

 RECT rect; GetWindowRect(hwnd, &rect); 

RECT itself is a structure

 typedef struct _RECT { LONG left; LONG top; LONG right; LONG bottom; } RECT; 
+17
source

You can get the window coordinates:

 lpRect->left lpRect->right lpRect->top lpRect->bottom 

Additional information here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd162897(v=vs.85).aspx

+3
source

Source: https://habr.com/ru/post/1497604/


All Articles