Home
Fractals
Tutorials
Books
My blog
My LinkedIn Profile

BOOKS i'm reading

Napoleon Hill Keys to Success: The 17 Principles of Personal Achievement, Napoleon Hill, ISBN: 978-0452272811
The 4-Hour Workweek: Escape 9-5, Live Anywhere, and Join the New Rich (Expanded and Updated), Timothy Ferriss, ISBN: 978-0307465351
The Fountainhead, Ayn Rand, ISBN: 0452273331

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

Olivier Langlois, IT superstar coach, Dominate LinkedIn Formula author
by Olivier Langlois

Contents





The demo program

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.

Limitations and suggestions for enhancements

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.

Conclusion

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!

Bibliography

History

  • 02-13-2006
    • Original article.
Tweet


Page 1 2 3

Back to the tutorials list

Home :: Fractals :: Tutorials :: Books :: My blog :: My LinkedIn Profile :: Contact