ID: Q149330
The information in this article applies to:
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.
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:
1. Add a new module to the project. If one or more modules already exist,
these can be used instead of adding a new module.
2. 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)
3. 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
Microsoft has confirmed this to be an issue in the Microsoft products listed at the beginning of this article. This problem has been fixed in Microsoft Windows 98.
1. Start Visual Basic 4.0, 16-bit edition on Windows 95.
2. 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
3. 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.
Additional query words: kbVBp400bug kbVBp kbWinOS98fix kbdsd kbDSupport
kb16bitonly kbNoKeyWord
Keywords : kbVBp400bug
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbfix
Last Reviewed: November 11, 1998