PRB: Toolbar Buttons Not Updated/Painted Correctly in Windows 95 (168289)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Editions 4.2b
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
This article was previously published under Q168289 SYMPTOMS
Buttons on a toolbar that were created using CToolBar may not update or
paint correctly if the buttons have text associated with them. This happens
only on Windows 95 machines with Internet Explorer 3.x installed.
CAUSE
This is due to a bug in the ComCtl32.dll (version 4.70) that is installed
with Internet Explorer 3.x.
RESOLUTION
To work around this problem, derive a class from CToolBar and override
DefWindowProc as follows:
// MyToolBar.h : headerfile
class CMyToolBar : public CToolBar
{
...
protected:
virtual LRESULT DefWindowProc(UINT message, WPARAM wParam,
LPARAM lParam);
...
};
// MyToolBar.cpp : implementation file
#include "stdafx.h"
#include "mytoolbar.h"
...
LRESULT CMyToolBar::DefWindowProc(UINT message, WPARAM wParam,
LPARAM lParam)
{
// the toolbar common control does not handle these messages well
// if the WS_VISIBLE style is not turned on under Windows 95
DWORD style = GetStyle();
if (message == TB_DELETEBUTTON || message == TB_INSERTBUTTON)
{
if (!(style & WS_VISIBLE))
{
ModifyStyle(0,WS_VISIBLE);
}
}
LRESULT lresult = CToolBar::DefWindowProc(message, wParam, lParam);
if (message == TB_DELETEBUTTON || message ==TB_INSERTBUTTON)
{
if (!(style & WS_VISIBLE))
{
ModifyStyle(WS_VISIBLE,0);
}
}
return lresult;
}
You can derive the CToolBar by using ClassWizard to derive from "generic
CWnd" and changing all CWnd references to CToolBar.
STATUS
Because Microsoft Visual C++, version 6.0 requires Internet Explorer 4.01,
Service Pack 1, this problem no longer exists in Visual C++, version 6.0.
Modification Type: | Major | Last Reviewed: | 12/8/2003 |
---|
Keywords: | kbNoUpdate kbprb kbToolbar KbUIDesign KB168289 |
---|
|