form class bug, or am I doing something wrong? 
Author Message
 form class bug, or am I doing something wrong?

Make a new project and add a form to it, then add this code:

Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.IsMdiContainer = True
Me.WindowState = FormWindowState.Maximized
Dim child1 As New Form()
child1.MdiParent = Me
child1.Show()
Me.Left = 0
Me.Width = 0
child1.Hide()
'child1.Visible = False
child1.Top = Me.ClientSize.Height / 2
child1.Left = Me.ClientSize.Width / 2
child1.Show()
'child1.Visible = True
End Sub

The child form appears not to move properly when invisible, either by
toggling the .visible property or calling the .Show/.Hide methods. Put
breakpoints on child1.Show() and End Sub... you will see that the .Left and
.Width properties change when the form is made visible - to niether their
initial values, nor the values specified in code.

Anyone know how I can properly move an MDI child form without first making
it visible?

Bob



Sun, 30 Jan 2005 06:07:21 GMT  
 form class bug, or am I doing something wrong?
We need to raise this as an issue with the Framework group, to find out if
this is a bug or is by design.

But a workaround, of sorts, is the following:

    Dim child1 As New Form()

    Private Sub Form1_Load(ByVal sender As Object, _
                           ByVal e As System.EventArgs) _
            Handles MyBase.Load
        Me.IsMdiContainer = True
        Me.WindowState = FormWindowState.Maximized
        child1.MdiParent = Me
        child1.Hide()
    End Sub

    Private Sub Form1_MdiChildActivate(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.MdiChildActivate
        child1.Top = Me.ClientSize.Height / 2
        child1.Left = Me.ClientSize.Width / 2
        child1.Width = 100
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
        child1.Show()
    End Sub

Obviously, if you had multiple child windows, your MdiChildActivate needs to
be more sophisticated than our simple example.

If you hadn't noticed it by yourself by now, may we point out that the
change from assigned value to system-chosen value happens on *either* a
change from invisible to visible *or* on a change from visible to invisible.
So the change in state is triggering it, and it this consistency that makes
us wonder if it is by design, for some reason we don't know.

Thanks,
VB Team

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> Make a new project and add a form to it, then add this code:

> Private Sub Form1_Load(ByVal sender As Object, _
> ByVal e As System.EventArgs) Handles MyBase.Load
> Me.IsMdiContainer = True
> Me.WindowState = FormWindowState.Maximized
> Dim child1 As New Form()
> child1.MdiParent = Me
> child1.Show()
> Me.Left = 0
> Me.Width = 0
> child1.Hide()
> 'child1.Visible = False
> child1.Top = Me.ClientSize.Height / 2
> child1.Left = Me.ClientSize.Width / 2
> child1.Show()
> 'child1.Visible = True
> End Sub

> The child form appears not to move properly when invisible, either by
> toggling the .visible property or calling the .Show/.Hide methods. Put
> breakpoints on child1.Show() and End Sub... you will see that the .Left
and
> .Width properties change when the form is made visible - to niether their
> initial values, nor the values specified in code.

> Anyone know how I can properly move an MDI child form without first making
> it visible?

> Bob



Wed, 02 Feb 2005 04:53:18 GMT  
 form class bug, or am I doing something wrong?
I sure hope that's a bug. If you get more information please post it to this
thread.

thanks,
Bob

P.S. and a big thanks in general for you guys always being here to answer
questions.



Quote:
> We need to raise this as an issue with the Framework group, to find out if
> this is a bug or is by design.

> But a workaround, of sorts, is the following:



Fri, 04 Feb 2005 22:05:56 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Am I doing something wrong ?

2. Am I doing something wrong...??

3. Am I doing something wrong...??

4. Obviously I'm doing something wrong!

5. Bug in VB.Net or am I doing something wrong? *sigh*

6. I must be doing something wrong here

7. Is this a bug or am I doing something wrong?

8. BUG??? or am I doing something wrong...

9. BUG??? or am I doing something wrong...

10. Am I Doing Something Wrong, Is It A Bug, Or An Undocumented Feature?

11. Recordset: What am I doing wrong?

12. What am I doing wrong??

 

 
Powered by phpBB® Forum Software