Microsoft KB Archive/149330

= FIX: Form Icon Does Not Change on Win95 When Set at Run- Time =

Article ID: 149330

Article Last Modified on 10/15/2002

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition

-



This article was previously published under Q149330



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.



RESOLUTION
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. This problem has been fixed in Microsoft Windows 98.



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 </li> 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.</li></ol>

Keywords: kbbug kbfix kboswin98fix kb16bitonly KB149330

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.