Article ID: 151031 - Last Review: November 21, 2006 - Revision: 3.1 FIX: SetMinHeight Does Not Work Correctly with CStatusBarThis article was previously published under Q151031 On This PageSYMPTOMS
Using the SetMinHeight function to change the height of a CStatusBar object
has no effect.
CAUSE
The CStatusBar class maintains the height of the status window control in a
member variable named m_nMinHeight. The m_nMinHeight variable is not
updated correctly when the SetMinHeight function is used to change the
height of the status bar.
RESOLUTION
You can work around this problem by setting m_nMinHeight to the correct
value in response to SetMinHeight. This is accomplished by deriving a class
from CStatusBar and handling the SB_SETMINHEIGHT message. In this handler,
call Default(), and then set m_nMinHeight to the new height.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This problem was corrected in Visual C++
version 6.0.
MORE INFORMATION
The sample code below illustrates how to work around the problem. Use the
CMyStatusBar class instead of CStatusBar if you want to change the height
of the status bar using SetMinHeight function. Be sure to call RecalcLayout
on the parent of the status bar to see this change in height immediately.
NOTE: The workaround uses the undocumented m_nMinHeight member variable of CStatusBar. Hence the code in the workaround may not be compatible with future versions of MFC. Sample CodeREFERENCES
For more information, please see: Visual C++ Books Online, and the Win32
SDK documentation.
APPLIES TO
| Article Translations
|

Back to the top
