We help IT Professionals succeed at work.

Overloading onSize

win32
win32 asked
on
Medium Priority
499 Views
Last Modified: 2013-11-20
Hi

I wanna overload onsize, but not realy sure how to do it. Problem: My application is resizeable... but the application should not be smaler then 400 * 400.

OnSize(..)
{
  //When new size is smaler then 500 * 500 pixels.. don't   resize
}

But, how is that done ?

CB
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Hi win32,

to avoid flickering it's better to restrict window-sizes by handling the WM_GETMINMAXINFO
message. Override CWnd::OnGetMinMaxInfo() for your window's class and in there simply
set the ptMinTrackSize member of the passed MINMAXINFO to 500, 500.

hope that helps,

ZOPPO
I agree - here's an example from one of my own apps - if limits the size and screen position of a dialog:

void CMaterialListDlg::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
    CRect parentRect;
    m_pParent->GetClientRect(&parentRect);

    lpMMI->ptMaxSize.x      = GetSystemMetrics(SM_CXSCREEN);
    lpMMI->ptMaxSize.y      = parentRect.Height();
    lpMMI->ptMaxPosition.x  = 10;
    lpMMI->ptMaxPosition.y  = parentRect.Height() / 2;
    lpMMI->ptMinTrackSize.x = GetSystemMetrics(SM_CXSCREEN) / 2;
    lpMMI->ptMinTrackSize.y = parentRect.Height() / 2;
    lpMMI->ptMaxTrackSize.x = GetSystemMetrics(SM_CXSCREEN);
    lpMMI->ptMaxTrackSize.y = GetSystemMetrics(SM_CXSCREEN) / 2;

    CDialog::OnGetMinMaxInfo(lpMMI);
} // end OnGetMinMaxInfo()

Author

Commented:
I have doen like this:

void CChildView::OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI )
{
     POINT pMin;
     pMin.x = 100;
     pMin.y = 100;
     lpMMI->ptMinTrackSize = pMin;
     CWnd::OnGetMinMaxInfo(lpMMI);
}


But it does not work ???
Thought you wanted it to be 400 * 400 or 500 * 500???

Also, looks like you want to make sure a child frame in an MDI app is what you want to restrict, correct??
CERTIFIED EXPERT

Commented:
And, maybe you should modify the values after you called CWnd::OnGetMinMaxInfo()
coz maybe there the values are modified again...

Author

Commented:
Hmm I made a mistake, I was modifying a child wnd to the main wnd.. now it works :-)
CERTIFIED EXPERT

Commented:
:(

I'm not happy about this because you simply accepted captainkirk's comment as answer
without telling a reason what's wrong with my comment.
zoppo - I'd like to give you the points 'cuz you were the one who made the correct suggestion first -- look for a Q in the MFC section.... see ya later...

Explore More ContentExplore courses, solutions, and other research materials related to this topic.