How would I get the current length and width of my window? (seperately prefered).
How would I get the current length and width of my window? (seperately prefered).
"If you tell the truth, you don't have to remember anything"
-Mark Twain
Use GetClientRect():
BOOL GetClientRect(
HWND hWnd, // handle of window
LPRECT lpRect // address of structure for client coordinates
);
Parameters
hWnd
Identifies the window whose client coordinates are to be retrieved.
lpRect
Points to a RECT structure that receives the client coordinates. The left and top members are zero. The right and bottom members contain the width and height of the window.
Hey,
Just a side note as that should be what you want but you said window dimentions.
Use GetWindowRect().
Thanks
TNT
TNT
You Can Stop Me, But You Cant Stop Us All
As an addition to these.. this is what the RECT structure is:
Good luck.The RECT structure defines the coordinates of the upper-left and lower-right corners of a rectangle.
typedef struct _RECT { // rc
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;
Members
left
Specifies the x-coordinate of the upper-left corner of the rectangle.
top
Specifies the y-coordinate of the upper-left corner of the rectangle.
right
Specifies the x-coordinate of the lower-right corner of the rectangle.
bottom
Specifies the y-coordinate of the lower-right corner of the rectangle. The RECT structure defines the coordinates of the upper-left and lower-right corners of a rectangle.
typedef struct _RECT { // rc
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT;
Members
left
Specifies the x-coordinate of the upper-left corner of the rectangle.
top
Specifies the y-coordinate of the upper-left corner of the rectangle.
right
Specifies the x-coordinate of the lower-right corner of the rectangle.
bottom
Specifies the y-coordinate of the lower-right corner of the rectangle.
How do I get dimentions out of that?
"If you tell the truth, you don't have to remember anything"
-Mark Twain
Well it should be self-explanatory, but...
then, as was stated alreadyCode:RECT *rect; ... GetWindowRect(hwnd, rect);
so rect.left would now be the x-coordinate of the upper-left corner of the window, rect.top would be the y-coordinate of the upper-left corner of the window, etc.left
Specifies the x-coordinate of the upper-left corner of the rectangle.
top
Specifies the y-coordinate of the upper-left corner of the rectangle.
right
Specifies the x-coordinate of the lower-right corner of the rectangle.
bottom
Specifies the y-coordinate of the lower-right corner of the rectangle.
Just incase you're still stuck.. uhm.. I doubt you are..
Width = Rect.right - Rect.left;
Height = Rect.bottom - Rect.top
But that's obvious..
RECT *rect;
...
GetWindowRect(hwnd, rect);
No, it's.....
RECT rect
...
GetWindowRect(hWnd,&rect)
btw, thanx ExDigit
"If you tell the truth, you don't have to remember anything"
-Mark Twain
that's what I get for typing fast
Hey, thanks anyways. I got what I needed from you guys.
"If you tell the truth, you don't have to remember anything"
-Mark Twain
I get them in WM_SIZE:
Code:case WM_SIZE: cxClient = LOWORD(lParam); cyClient = HIWORD(lParam);
1978 Silver Anniversary Corvette
Or for the whole screen
Code:iWidth =GetDeviceCaps(GetDC(NULL) ,HORZRES); iHeight =GetDeviceCaps(GetDC(NULL) ,VERTRES);
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Hey another for screen dimensions:
CheersCode:int cx = GetSystemMetrics(SM_CXSCREEN); int cy = GetSystemMetrics(SM_CYSCREEN);
TNT
TNT
You Can Stop Me, But You Cant Stop Us All
If you're using MFC:
CRect rect;
It has member functions like
rect.Width();
rect.Height();
and many more.
You aquire the rect the same way as with the regular RECT structure
Don't talk to strangers, unless they offer candy.