Quote Originally Posted by JitterJaw View Post
Hi all,
Here is a problem Im working on for a couple of days now:
I have my main dialog, and when a button is pressed in that main dialog, I call a function in another dialog and load some variables, without showing the dialog,or calling DoModal. In the second dialog, when executing the function the following code is executed:

m_st1.GetClientRect( &rectStaticClient );

where m_st1 is a CStatic control of a picture control. The width & height of the rect I get is zero. but when I call the same function from the second dialog I do get the right size. so my question is, do I have to DoModal in order to get the size of a picture control box ? or am Im missing something ?
Thanks to all answers....
The dialog window must be created before calling GetClientRect() of it or of it's members.

Code:
if (m_st1.GetSafeHwnd()) 
{
  m_st1.GetClientRect( &rectStaticClient );
}
else
{
  // not created yet.
}
Windows does not know the size of the controls before the dialog window has been created.

Btw: In a debug session you should get an assertion. Did you try to debug it?

With regards
Programartist