Sizing Dialog COntrols

I am trying to make my controls inside a dialog box size accordingly whenever the dialog box is maximized or the user drags the edges of the dialog.

But OnSize is called the moment the dialog is launched,  which causes a debug Assertion becoz I am calling a GetViewRect of a list view to size it with the dialog.

How do I go about this problem... How do I capture the event that only occurs when the user drags the Edges of a Dialog box to SIze it or when the Maximize button is pressed????

what are the windows messages??

thanks.


load_o_crapAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:
Hi,

In OnSize() function u can check for it. It is giving assertion as that list view control is still not there. Lets say u have the control variable m_OfflineList associated with that list control. then in OnSize() function resize it as

if(m_OfflineList.m_hWnd)
{
    //Write Ur sizing code here
}

Hope that helps.

VinExpert
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vinayak KumbarSr Program ManagerCommented:
Hi,

In OnSize(), The code may look something like

CRect mrect, mrect1;

if(m_OfflineList.m_hWnd)
{
mrect.top = mrect.bottom = mrect.right = mrect.left = 0;
m_OfflineList.GetWindowRect(&mrect);
ScreenToClient(&mrect);
            m_OfflineList.SetWindowPos(&m_OfflineList.wndTop,10,mrect.top,cx-115,                                      cy-85,SWP_SHOWWINDOW |SWP_NOZORDER);
}

Try it out.

VinExpert
0
load_o_crapAuthor Commented:
But isnt it better to detect a windows message event becoz for the case of a minimize/maximize button being pressed I wouldn't know which from which...

0
Vinayak KumbarSr Program ManagerCommented:
Hi,

Does it solved Ur assertion!!?
If u want to do some specific things depending on the window state, then put the following code in the OnSize() function for that dialog

WINDOWPLACEMENT wndpl;
wndpl.length = sizeof(WINDOWPLACEMENT);
BOOL bRet = GetWindowPlacement(&wndpl);
if (wndpl.showCmd == SW_SHOWNORMAL)
{
      //Do The Normal Window Things
}
else if (wndpl.showCmd == SW_SHOWMAXIMIZED)
{
      //Do The Maximised Window Things
}
else if (wndpl.showCmd == SW_SHOWMINIMIZED)
{
      //Do The Minimised Window Things
}

To check for minimise state, u can use
if(this->IsIconic())
  AfxMessageBox("Window is minimised");

Hope this helps.

VinExpert.
0
V_BapatCommented:
I have a class which does the job for you. Do you want me to send it to you?

Vicky
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.