Click here to Skip to main content
15,920,670 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
How can i stop user from resizing window upto certain limit? I do want to allow user for resizing a window upto some certain limit. If User try to resize window beyond that limit, program must not allow him to do so.
Posted

Override CWnd::OnGetMinMaxInfo. See here[^] for a whole discussion about it.
 
Share this answer
 
Done !! Thanks a lot.

But i have change limit.

lpMMI->ptMinTrackSize.x = 1000; 
lpMMI->ptMinTrackSize.y = 700;


in place of
lpMMI->ptMaxTrackSize.x = 1000; 
lpMMI->ptMaxTrackSize.y = 700;


I have done this change because i do want to stop user from resizing from maximum to minimum. not from minimum to maximum.
 
Share this answer
 
Sorry :)

C++
BEGIN_MESSAGE_MAP(CYourWnd, CBaseOfYouWnd)
  //{{AFX_MSG_MAP(CYourWnd)
...
  ON_WM_GETMINMAXINFO()
  //}}AFX_MSG_MAP
END_MESSAGE_MAP()
    
void CYourWnd::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
{
  lpMMI->ptMaxTrackSize.x = 400;
  lpMMI->ptMaxTrackSize.y = 200;
}
 
Share this answer
 
Is there a stop at some breakpoint inside the function OnGetMinMaxInfo ? :)
 
Share this answer
 
Thanks for your reply but this idea is not working.
 
Share this answer
 
Hello Eugen,

I tried with your code but it is giving me "Debug Assertion Failed". Somewhere i am missing something.

what would be m_cMaxRect?
 
Share this answer
 
Eugen, Problem not solved.
User is able to resize window. window is not limiting to certain limit.
 
Share this answer
 
In visual studio , you when you select a Form, in the properties, you can see a Field called Maximum Window size. you can give a maximum size in pixels. so the user cant increase that value.
 
Share this answer
 
Storm, I am using MFC Application in VS 2003. The property which are you talking about in not available in this. so i am not able to set property which you were talking about.
 
Share this answer
 
Eugen, I also implemented this logic. but i did not get success in this. May be i was doing something wrong. After implementing your mentioned function, how to use this? can you tell me?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900