BUG: Form Icon Does Not Change on Win95 When Set at Run Time

Last reviewed: April 4, 1996
Article ID: Q149330
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:

  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

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

  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 reference words: 4.00 vb4win vb4all
KBCategory: kbprg kbbuglist
KBSubcategory: PrgOther




THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 4, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.