Re: Maximize box with all windows
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Fri, 09 Feb 2007 11:30:01 -0500
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.Joseph M. Newcomer [MVP]
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 ?
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Maximize box with all windows
- From: Mammoth
- Maximize box with all windows
- Prev by Date: Re: New to VC/MFC
- Next by Date: Re: Problem with HUGE_VAL
- Previous by thread: Re: Maximize box with all controls
- Next by thread: re: CRITICAL SECTION Help! Array?
- Index(es):
Relevant Pages
|
Loading