Re: Make client area of frame view a certain (fixed) size (AdjustWindowRectEx
problem)
Mark Salsbery [MVP] wrote:
"WP" <invalid@invalid.invalid> wrote in message
news:6fc02iFaqbcdU1@mid.individual.net...
Hello, I'm trying to port a program written in raw Win32 (so I can ask
for help regarding it here) to MFC and I've run into a problem. The
program is supposed to be fixed in size and the client area must be of
size 400 * 400. The Win32-program uses AdjustWindowRectEx() to
calculate the needed width and height that should be passed to
CreateWindow() when the main window (which is, in fact, the only
window in the program) is created and that works fine.
My MFC version is an SDI-program without doc/view support but the
frame window does have a view. So I tried to call
::AdjustWindowRectEx() in
PreCreateWindow() in the frame but the rect contains garbage values
after the call...The styles I'm passing are those found in the
CREATESTRUCT (style and dwExStyle). I also tried to hardcode the styles:
WS_CAPTION | WS_BORDER | WS_MINIMIZEBOX | WS_SYSMENU and 0 for the
extended styles, but the rect still contains garbage after the call...
Can you post the code? What is AdjustWindowRectEx() returning?
Mark
Yeah, you're right. Too little information in my question. The reason I
didn't post any code is because it's really simple. Anyway, here is the
full PreCreateWindow in the frame. ::AdjustWindowRectEx() returns 1 but
it contains garbage values afterwards, values that seem uninitialized to
me (they just contain what bits happens to be in the memory where they
are located).
BOOL DoubleBufferingMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
VERIFY(CFrameWnd::PreCreateWindow(cs));
::RECT rect;
BOOL b = ::AdjustWindowRectEx(&rect, WS_CAPTION | WS_BORDER |
WS_MINIMIZEBOX | WS_SYSMENU, 0, TRUE);
cs.cx = 400;
cs.cy = 400;
cs.lpszClass = AfxRegisterWndClass(0);
return TRUE;
}
The way I set cx and cy now is just temporary until I can calculate them
properly.
- Eric (WP)