FIX: LoadBarState and SaveBarState Increase .Ini File Size (138722)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 2.1
This article was previously published under Q138722 SYMPTOMS
The size of the .ini file associated with an application keeps increasing
when CFrameWnd::LoadBarState and CFrameWnd::SaveBarState functions are
used. The docktool sample can be used to reproduce the behavior. Open and
close the sample application without modifying the toolbars. The .ini file
size increases every time the application is closed.
CAUSE
This behavior is due to a bug in one of the helper functions of
CControlBar. CFrameWnd::LoadBarState calls this function to set the state
of a control bar. This function adds a trailing NULL element to the
internal structure maintaining state information, without checking if one
is already present. CFrameWnd::SaveBarState stores this extra element in
the .ini file. The next time CFrameWnd::LoadBarState is called, another
NULL element is added to the state information and the cycle continues.
RESOLUTION
To prevent the .ini file from growing, remove the extra element from file.
This can be done after the information has been saved. The "Sample Code to
Resolve Problem" section in this article shows how to implement this. It
reads the information stored in the .ini file, strips extra trailing NULL
elements, and saves the information back to the file. The code uses classes
private to MFC, and the preprocessor directives ensure that the code is
compatible with future versions of MFC.
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 the MFC
libraries included with Microsoft Visual C++, 32-bit Edition, version 2.2.
Modification Type: | Major | Last Reviewed: | 10/17/2003 |
---|
Keywords: | kbBug kbcode kbfix kbNoUpdate KbUIDesign KB138722 |
---|
|