The information in this article applies to:
- Professional and Enterprise Editions of Microsoft Visual Basic,
16-bit only, for Windows, version 4.0
SYMPTOMS
When the icon for a form is changed at run time and the form is then
minimized, the taskbar icon does not reflect this change. This problem only
occurs with the 16-bit version of Visual Basic and Windows 95.
WORKAROUND
To work around this problem, add a call to the SetClassWord function
immediately after changing the icon. This will update the information for
the window and the correct icon will be displayed when the window is
minimized. To implement this fix, follow these steps:
- Add a new module to the project. If one or more modules already exist,
these can be used instead of adding a new module.
- Add the following function and constant declarations to the module:
Declare Function SetClassWord Lib "User" (ByVal hWnd As Integer, _
ByVal nIndex As Integer, ByVal wNewWord As Integer) As Integer
Public Const GCW_HICON = (-14)
- Immediately after changing the icon in code, add this call to
SetClassWord (assuming Form1 is the form where the icon was changed):
SetClassWord Form1.hWnd, GCW_HICON, Form1.hWnd
STATUS
Microsoft has confirmed this to be an issue in the Microsoft products
listed at the beginning of this article. Microsoft is researching this
problem and will post new information here in the Microsoft Knowledge Base
as it becomes available.
MORE INFORMATION
Steps To Reproduce
- Start Visual Basic 4.0, 16-bit edition on Windows 95.
- Add the following code to the Form_Click event of Form1. Be sure to
change the path in the LoadPicture call to reflect your installation of
Visual Basic.
Private Sub Form_Click()
Form1.Icon = LoadPicture("c:\vb4\icons\writing\books01.ico")
MsgBox "Icon changed"
End Sub
- Press F5 or select Start from the Run menu to run the application.
Minimize the form and see that the icon is the default Visual Basic form
icon. Maximize the form, click on it, and see the "Icon Changed" message
box. Now minimize the form again. On Windows NT 3.51 or a 16-bit Windows
platform, the icon will have changed; on Windows 95, it will not be
changed. Implementing the fix outlined in the Workaround section above
will fix the problem.
|