From: bharath_r on
Hi All,

I am trying to create a MFC application with Re-sizable PropertySheet.
I have followed the following MSDN article on how to create a re-
sizable PropertySheet.
http://support.microsoft.com/kb/325613

But my problem is, it all works well in debug mode. When its in
release mode the GetWindowRect or the GetClientRect for that matter,
returns some insane values. I am wondering what the problem might be.
While i was searching for this, i found a thread where one person had
this same problem with GetWindowRect in release mode. But atleast he
said he used to get some error when he did GetLastError, for me though
it returns zero. So i'm really not sure what is causing this. Any help
is highly appreciated.

Thanks,
Bharath
From: David Lowndes on
>But my problem is, it all works well in debug mode. When its in
>release mode the GetWindowRect or the GetClientRect for that matter,
>returns some insane values.

You clearly have a problem, but it isn't related to those APIs - their
behaviour can't change between a debug/release build of your code,
since they're part of the OS.

>I am wondering what the problem might be.

Possibly some uninitialised variable?

If you're using a recent version of Visual C++, ensure your debug
build has the run-time checking compiler options enabled, they may
help identify such problems.

Dave
From: Joseph M. Newcomer on
GetWindowRect returns screen coordinates, and thus you must use ScreenToClient if you need
client coordinates.

The MoveWindow is a bit weird, because it uses the screen coordinates to "move" the window
on the screen without actually moving it. This is beacuse it was probably written by some
summer intern as his/her first Windows program, having been handed one book on Windows
programming in preparation. A real programmer would have written

SetWindowPos(NULL, 0, 0, r.Width(), r.Height + ::GetSystemMetrics(SM_CYMENU), SWP_NOMOVE |
SWP_NOZORDER);

MoveWindow to change only one parameter is used only by programmers who have read one
introductory book to Windows and never looked at real code.

But I have no idea what constitute "insane values"; I've used GetWindowRect a lot, and
never seen bad values come back. So actual numbers would be required to show why it is
not working.

I note that there is no UpdateWindow preceding it, and this might mean that since the
window is normally invisible during OnInitDialog, and is not made visible until you
return, that you may have to define a user-defined message,and PostMessage a request using
this message ID, and in the handler do the window placement, This is because the window
may not really be valid until after OnInitDialog. But by using PostMessage, you guarantee
that the post-OnInitDialog code that makes the window visible has been executed.. See my
essay on message management on my MVP Tips site for more information.
joe


On Wed, 14 Apr 2010 00:24:20 -0700 (PDT), bharath_r <bharath.0523(a)gmail.com> wrote:

>Hi All,
>
>I am trying to create a MFC application with Re-sizable PropertySheet.
>I have followed the following MSDN article on how to create a re-
>sizable PropertySheet.
>http://support.microsoft.com/kb/325613
>
>But my problem is, it all works well in debug mode. When its in
>release mode the GetWindowRect or the GetClientRect for that matter,
>returns some insane values. I am wondering what the problem might be.
>While i was searching for this, i found a thread where one person had
>this same problem with GetWindowRect in release mode. But atleast he
>said he used to get some error when he did GetLastError, for me though
>it returns zero. So i'm really not sure what is causing this. Any help
>is highly appreciated.
>
>Thanks,
>Bharath
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm