VB Extra Resize Event when WindowState Not Normal (Not 0)

ID Number: Q79116

1.00

WINDOWS

buglist1.00

Summary:

An extra Resize event will occur when a Visual Basic form is unloaded

if that form's WindowState property is set to either 1 (Minimized) or

2 (Maximized).

Microsoft has confirmed this to problem with Microsoft Visual Basic

programming system version 1.0 for Windows. We are researching this

problem and will post new information here as it becomes available.

More Information:

Workaround

----------

To avoid performing code in the Form_Resize event for this extra

Resize event, you can set a global variable in the form's Unload event

procedure that you can check in the Resize event procedure to

determine if a normal Resize or an extra Resize event is occurring.

To work around this problem, add the following code to the program:

1. Dimension a flag variable in the General - Declarations section of

the form in question:

Dim ExtraEventFlag%

2. Set the flag in the Form_Unload event:

Sub Form_Unload (Cancel as Integer)

ExtraEventFlag% = -1

End Sub

3. Check the flag variable's value before performing code in the

Resize event:

Sub Form_Resize

If Not ExtraEventFlag% Then

Beep '** or other code for the Resize event..

End If

End Sub

The Form_Unload event should occur before the Form_Resize event, set

the flag variable, and prevent the code for the Resize event from

executing for this extra event.

Steps to Reproduce Problem

--------------------------

1. Start Visual Basic, or from the File menu, choose New Project.

2. In Form_Resize, add a Beep statement.

3. Set Form1.WindowState = 1 (Minimized).

4. Run the program. One beep occurs, and the minimized icon appears at

the bottom of the screen.

5. Double-click the icon to restore the form. A beep sounds,

indicating that a resize event has occurred.

6. Double-click the system menu of Form1 to close the form. Another

beep sounds, indicating that a resize event has occurred.

For forms with a Normal WindowState, no Resize event occurs when you

close the form.

Additional reference words: 1.00