fbpx

Control Client area minimum size (WM_GETMINMAXINFO) with MFC in C++

(Last Updated On: October 19, 2010)

Control Client area minimum size (WM_GETMINMAXINFO) with MFC in C++

Contents

This section’s purpose is to present the recipe for using CMinMaxFrame class. The demo program is just a plain vanilla MFC wizard generated program that has been modified to use CMinMaxFrame. Here are the steps needed to use CMinMaxFrame:

  • Edit your frame class header file and cpp file to replace every CFrameWnd occurrences for CMinMaxFrame
  • Call CMinMaxFrame::setToolBar() and CMinMaxFrame::setStatusBar() in your OnCreate() handler once the bars have been created
  • Specify the minimum size of your client view to the CMinMaxFrame constructor or call the function CMinMaxFrame::setClientMin() anytime you want.

This it it! It is that simple. Now you can play around. Remove and replace the status bar. Place the toolbar on any side of the frame. Your client area will always respect the minimum size that you specified.

Even if I am quite happy with the end result, this code is still not perfect. Here is a list of things that could be done:

  • Support more than 1 toolbar with a list
  • Support maximum size
  • Override PreCreateWindow() function to make sure that the 3 mandatory window style flags are always present.
  • Use documented MFC features as the current solution might not work anymore with future MFC releases.

When I wrote this article I had two goals in mind. First, help my fellow programmers that have encountered the same problem I did. Secondly, I hope to receive feedback from you if you find ways to improve the code. If you do so, I will update this article with your improvements.

That is it! I hope you enjoyed this C++ programming tutorial and that you have found it useful. In the next section, you will find the books that I have consulted to build this C++ Windows programming tutorial. Those books are great and filled with Windows programming gems that you should know. It is strongly recommended that you get yourself a copy of these books especially since from time to time, you can find these books at a bargain price. Take the time to check the prices. This is maybe your lucky day today!

  • 02-13-2006
    • Original article.
    • Page 1 2 3

Source: Thanks to Olivier Langlois

http://www.olivierlanglois.net/control_client_area_window_size_with_WM_GETMINMAXINFO_in_MFC3.html

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Subscribe For Latest Updates

Sign up to best of business news, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.

NOTE!

Check NEW site on stock forex and ETF analysis and automation

Scroll to Top