• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

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.


0
load_o_crap
Asked:
load_o_crap
  • 3
1 Solution
 
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
 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now