Article View: comp.windows.ms.programmer
Article #1359Can't get AdjustWindowRect to work
From: Russ Corfman
Date: Thu, 31 Jan 1991 22:16
Date: Thu, 31 Jan 1991 22:16
84 lines
3660 bytes
3660 bytes
Hi,
I'm trying to get my application's window to be a certain size.
It is going to have a number of controls in it, so I used the
dialog editor to design the client area. Using the dialog editor,
I came up with the placement of all the controls and the size (in
dialog units) of the client area.
Next, I converted the client area from dialog units to device units
then attempted to get the window's needed dimensions (client area
plus borders, menu, and caption) using the AdjustWindowRect function.
After that, I created the window using the (supposedly) adjusted
rectangle.
My problem is that the window's final size was exactly the size
of the wanted client area. I verified this by moving the application
window over the working window in the dialog editor. It appears
that the AdjustWindowRect did not adjust the rectangle at all. The
code I used is as follows:
RECT Rect;
long dlg_units;
/* figure out how big the client area needs to be */
dlg_units = GetDialogBaseUnits();
Rect.left = 0;
Rect.top = 0;
Rect.right = ((X_LEN * LOWORD(dlg_units)) / 4);
Rect.bottom = ((Y_LEN * HIWORD(dlg_units)) / 8);
/* adjust the size of the window to fit the client area */
AdjustWindowRect(&Rect,
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX,
TRUE);
/* create the window */
hWnd = CreateWindow("MyWClass",
"My Window",
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT,
CW_USEDEFAULT,
Rect.right,
Rect.bottom,
Null,
MyMenu,
hInstance,
NULL);
I tried changing the window style passed to AdjustWindowRect with
no change. I also passed FALSE (no menu) and again no change. The
documentation doesn't really explain where the adjusted rectangle
ends up. The function is a void. It would have been nice if it
returned the adjusted rectangle. I assumed it just modified the
passed rectangle. One thing I just thought of is that it may have
modified the upper left corner of the rectangle. I was assuming it
modified the lower right since client windows always have an upper
left corner of (0,0). If this is the case, it seems a bit inconsistent
to me. I'll try that tonight with the following:
hWnd = CreateWindow("MyWClass",
"My Window",
WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX,
CW_USEDEFAULT,
CW_USEDEFAULT,
/* change */ Rect.right - Rect.left,
/* change */ Rect.bottom - Rect.top,
Null,
MyMenu,
hInstance,
NULL);
If that solves the problem, sorry to bother everyone, except any
readers from Microsoft. Please if this is the case, have someone
update the manual to explain how the function returns the
adjusted rectangle!
Ciao,
--
Russell Corfman (corfmanr@gtephx)
UUCP: {ncar!noao!asuvax | uunet!zardoz!hrc}!gtephx!corfmanr
AG Communication Systems (formerly GTE), Phoenix
(602) 581-4403
Technical Details
Message-ID:
<175@maillot_.gtephx.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!decwrl!elroy.jpl.nasa.gov!ncar!asuvax!hrc!gtephx!corfmanrShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!decwrl!elroy.jpl.nasa.gov!ncar!asuvax!hrc!gtephx!corfmanr From: corfmanr@gtephx.UUCP (Russ Corfman) Newsgroups: comp.windows.ms.programmer Subject: Can't get AdjustWindowRect to work Message-ID: <175@maillot_.gtephx.UUCP> Date: 31 Jan 91 22:16:58 GMT Organization: gte Lines: 84