BUG: Setting WindowState = 0 Doesn't Set Window State to Normal

Last reviewed: February 5, 1998
Article ID: Q180527
The information in this article applies to:
  • Windows CE Toolkit for Visual Basic 5.0, version 1.0

SYMPTOMS

Setting the WindowState property of a form to '0 - Normal' has no affect.

RESOLUTION

Save the form's height and width before changing the WindowState property (such as Maximizing), then restore the height and width when desired as follows:

   Option Explicit
   Dim FormHeight
   Dim FormWidth

   Private Sub Form_Load()
      'initialize form size, could be set at design-time also.
      Form1.height = 2000
      Form1.width = 3000
      'Save the form's height and width.
      FormHeight = Form1.Height
      FormWidth = Form1.Width
      Command1.Caption = "Maximized"
      Command2.Caption = "Normal"
   End Sub

   Private Sub Command1_Click()
      Form1.WindowState = 2 'Maximized
   End Sub

   Private Sub Command2_Click()
      'Restore the form's original height and width.
      Form1.Height = FormHeight
      Form1.Width = FormWidth
   End Sub

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start a new Windows CE Project in Visual Basic 5.0. Form1 is created by default.

  2. Add two CommandButtons to Form1, placing them in the upper-left-hand corner of the form so they will be visible when the form is resized by the Form's Load event (see step 3).

  3. Add the following code:

          Private Sub Form_Load()
    
               Command1.Caption = "Maximized"
               Command2.Caption = "Normal"
               'initialize form size, could be set at design-time also.
               Form1.height = 2000
               Form1.width = 3000
          End Sub
    
          Private Sub Command1_Click()
               Form1.WindowState = 2 'Maximized
          End Sub
    
          Private Sub Command2_Click()
               Form1.WindowState = 0 'Normal
          End Sub
    
    

  4. Press the F5 key to run the project.

  5. Click on Command1 and note that the Form is maximized.

  6. Click on Command2 and note that the Window does not return back to its Normal state.
Keywords          : vb5all vbce
Version           : WINDOWS:1.0
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbpending


================================================================================


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: February 5, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.