Home
Fractals
Tutorials
Books
Archive
My blog
My LinkedIn Profile

BOOKS i'm reading

Cryptography engineering, Niels Ferguson, Bruce Schneier, Tadayoshi Kohno, ISBN: 9780470474242
Advanced Programming in the UNIX(R) Environment (2nd Edition), W. Richard Stevens, Stephen A. Rago, ISBN:0201433079
Trading For a Living, Alexander Elder, ISBN:0471592242

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

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.

Page 1 2 3

Back to the tutorials list

Home :: Fractals :: Articles :: Books :: Archive :: My blog :: My LinkedIn Profile :: Contact