vs.net bug ?

D

David Gacek

The code that follows doesn't minimize the form and doesn't resize the Form
from code when the window state is changed at design time.

Are the two cases related to a bug in vs.net ?



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.Visible = False

Me.Hide()

'has to be a design time change

Me.WindowState = FormWindowState.Minimized

'Me.WindowState = FormWindowState.Normal

Dim x, y As String

x = 150

y = 200

Me.Width = y

Me.Height = x

Debug.WriteLine("x " & x & " y " & y)

Debug.WriteLine("Me.Height " & Me.Height & " Me.Width " & Me.Width)

End Sub
 
D

David Gacek

This is the full code ...
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.Visible = False

Me.Hide()

'has to be a design time change

Me.WindowState = FormWindowState.Minimized

'Me.WindowState = FormWindowState.Normal

Dim x, y As String

x = 150

y = 200

Me.Width = y

Me.Height = x

Debug.WriteLine("x " & x & " y " & y)

Debug.WriteLine("Me.Height " & Me.Height & " Me.Width " & Me.Width)

End Sub

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize

Static i As Integer

i += 1

Debug.WriteLine("Resize event " & i & " " & Me.Height & " " & Me.Width)

End Sub
 
G

Guest

David,

I can't find a bug. The Minimize and the re-size work for me. Why are you:
1. Me.Visible = False?
2. Me.Hide?

I wouldn't use strings to hold integers either.

If I do:
Me.WindowState = FormWindowState.Minimized
Me.Width = 150
Me.Height = 200
Then the form starts minimized and is a lot smaller than in design time.


Chris.
 
H

Herfried K. Wagner [MVP]

David Gacek said:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Me.Visible = False

Me.Hide()

What's the purpose of the lines above? When the 'Load' event handler is
executed, the form is not yet visible...
 
C

Cor Ligthert

Chris,

When I see it right, than it shows in the output window strange results.

Cor
 
C

Cor Ligthert

Herfried,

What's the purpose of the lines above? When the 'Load' event handler is
executed, the form is not yet visible...

When I see it right, than it shows in the output window strange results.

I have seen messages from you about when a form is hidded.

I was waiting for an answer from you, however not that one above.

Cor
 
H

Herfried K. Wagner [MVP]

David Gacek said:
The code that follows doesn't minimize the form and doesn't
resize the Form from code when the window state is changed
at design time.

Are the two cases related to a bug in vs.net ?

I checked your code and I am not sure what doesn't work for you. The form's
size is changed when it is minimized. The form is minimized if you remove
the first two lines in the 'Load' event handler, and it is minimized if your
keep them too, but the form won't be visible.
 
G

Guest

Cor,

I'm not sure I understand what you are saying. If I output to the debug
windows then I only get strange results if I Me.WindowState =
FormWindowState.Minimized. Once a form is minimized surely the forms size is
irrelevant.

Chris.
 
C

Cor Ligthert

Chris,

The me.width showed is not 200, however let's wait Herfrieds answer, I have
seen answers from him about this, although it was than forever about things
as tabpages.

Cor
 
H

Herfried K. Wagner [MVP]

Cor Ligthert said:
The me.width showed is not 200, however let's wait Herfrieds answer

I think this is by design. 'Height' and 'Width' return the current size of
the form, not the size the form would have if 'WindowState' is set to
'Normal'.

You can use p/invoke to get the form's size in normal window state, for
example:

Form Placement Component
<URL:http://www.codeproject.com/csharp/Placement.asp>
 
C

Cor Ligthert

Herfried,
I think this is by design. 'Height' and 'Width' return the current size
of the form, not the size the form would have if 'WindowState' is set to
'Normal'.

That is it in my opinion, I have seen this more,

Thanks

Cor
 
D

David Gacek

The problem was the stange results being displayed in the output window.

Thanks
I guess its that old "by design" thing again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top