Re: Maximize box with all windows



Yep. That's how it is supposed to work.

You need to resize the boxes as appropriate. Since Windows cannot understand the logic of
what you want resized, it cannot possibly do this.

Create an OnSize handler and resize the controls there.

Note that you should never hardwire any constants into your resize logic. Except
mulipliers and dirvisors, such as if you want a window half-size, you would use / 2.

Use GetWindowRect to get the window sizes, and don't assume you know what they are.


Here's some code that will resize a listbox (c_Log) which takes up the bottom part of the
dialog, from left-to-right across the entire dialog (note that to place it initially, you
have to turn off those stupid "guides" that keep you from stretching boxes out the whole
way across the area). It also lengthens the edit control c_Filename to fit all the way
across.

void CMyDialog::OnSize(UINT nType, int cx, int cy)
{
if(c_Log.GetSafeHwnd() != NULL)
{ /* log exists, resize it */
CRect r;
c_Log.GetWindowRect(&r);
ScreenToClient(&r);
c_Log.SetWindowPos(NULL,
0,0, // ignored, new position
cx, cy - r.top,
SWP_NOZORDER | SWP_NOMOVE);
} /* log exists, resize */

if(c_Filename.GetSafeHwnd() != NULL)
{ /* filename exists, resize */
CRect r;
c_Filename.GetWindowRect(&r);
ScreenToClient(&r);
c_Filename.SetWindowPos(NULL,
0, 0,
cx - r.left, r.Height(),
SWP_NOZORDER | SWP_NOMOVE);
} /* filename exists, resize */

Once you get comfortable with this idea, you quickly realize this is unbelievably tedious,
so you can investigate what are called "Layout managers". There are several available on
www.codeproject.com and www.codeguru.com. I try to avoid reallly complex situations where
they pay off well, and my code is rarely more complex than what you see above.

If you give the dialog a "thick frame" or "resizing frame" (the same thing, just different
terms), then you can drag its size around with the mouse. Then you should add an
invisible frame control and size it to the minimum size you want, and implement code as
below. You have to give the invisible frame an ID other than IDC_STATIC (e.g., IDC_FRAME)
and create a control variable for it, e.g., c_Frame

void CMyDialog::OnGetMinMaxInfo(LPMINMAXINFO * lpMMI)
{
CDialog::OnGetMinMaxInfo(lpMMI);

if(c_Frame.GetSafeHwnd() != NULL)
{ /* has frame */
CRect r;
c_Frame.GetWindowRect(&r);
ScreenToClient(&r);
CalcWindowRect(&r);
lpMMI->ptMinTrackeSize = CPoint(r.Width(), r.Height());
} /* has frame */
}

joe

On 9 Feb 2007 03:52:25 -0800, "Mammoth" <cactusek@xxxxxxxxx> wrote:

Hello.
I have dialog box with few resourses (edit boxes, list boxes etc) and
I added in properties of dialog box option : Maximize box. But when I
try to do this (push square in right top corner) then maximize only
main dialog box, but other reseourses like edit box and list boxes
have orginal size. How to do that all components expand when I
maximize dialog window ?
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: WMP control resizing
    ... > getting the WMP9 activex control in a window and playing movies etc. ... when you want to resize the control in MFC, ...
    (microsoft.public.windowsmedia.sdk)
  • Re: Outlook Custom form - resize event handling
    ... Is Inspector represents the message window itself? ... hook on the form and will resize... ... I used standard Message template and added custom control on ...
    (microsoft.public.office.developer.com.add_ins)
  • Re: Setwindowpos()-problem.Moving control is not happening.
    ... For this i need to resize and reposition the ... I am calling GetWindowRect to get the control ... >dimensions and after changing them i am trying to call SetWindowPos() ... if onlyresize means the window is ...
    (microsoft.public.vc.mfc)
  • Re: Outlook Custom form - resize event handling
    ... to get its size and resize my control. ... ownership for a WordMail Inspector window. ... What I usually do is to first of all avoid custom forms unless absolutely ...
    (microsoft.public.office.developer.com.add_ins)
  • Re: repainting own panel-component
    ... >> three seconds have passed and that the control needs to be repainted. ... the load when the window is being resized. ... When a resize operation ... stripes remains constant and they get thicker when the control grows, ...
    (comp.lang.pascal.delphi.misc)

Loading