• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

Child window resize problem

I'm converting my app from VB6 to VB2008. It starts with the first child window open in the MDI window. When I click on a button, I pass the top, left, width and height to the second child window Form_Load and it opens in the exact place of the first window and the first is unloaded. If I go back to the first, the reverse happens perfectly.

Now I'm trying to do the same with the next window using the same method in the Form_Load. But it opens with different top, left, height and width. I cannot figure where it is getting the new dimensions from. At the end of Form_Load, the dimensions are good. Then I put a breakpoint at the beginning of Form_Activate and the dimensions have changed.

One thing I loath about .NET is that single step really doesn't work. Without setting breakpoints at every procedure, I cannot figure out how to follow the flow of the program. If you don't know the sequence of flow in the program, how are you supposed to write code with predictable behavior?
0
LeeLiam
Asked:
LeeLiam
  • 2
  • 2
1 Solution
 
ladarlingCommented:
Can we see some code?
In .NET you would use something like:
FormB.Size = FormA.Size
FromB.Location = FormA.Location

One thing I loath about .NET is that single step really doesn't work.
You can step through one line at a time, use F8.
0
 
rionrocCommented:
Hello

In my opinion, vb.net has a different behavior than vb6, so you must follow the flow of vb.net.



Great is our GOD.
:)
0
 
LeeLiamAuthor Commented:
ladarling,

I 'm using:
        With Me
            .Top = (TP)
            .Left = (LP)
            .Height = (HP)
            .Width = (WP)
        End With
in the Form_Load event of the second form. I set the parameters when I leave the first form.

I tried your suggestion for Size and Location and I still get a smaller form than the first. In other words, exact same behavior.

Somewhere between the end of the Form_Load event and the point where the form appears on the screen, the dimensions are getting reset and I cannot figure it out.

BTW, I'm very familiar with F8. I've used it quite alot. The problem is that in .NET it will single step in the one procedure, but then it may skip other procedures. For example, after I single step through the Form_Load event and get to the end, the form appears. However, If I set a breakpoint at the Form_Activate, it stops there after Form_Load. Apparently, if you don't set breakpoints at every procedure, it skips them. VB6 did not do this. It went from procedure to procedure. I cannot get .NET to do this. Is there a setting or something I need to set?

rionroc,

You have a great idea there. I would love to follow the flow of vb.net, if I had any clue where the flow is going. That's my problem. Procedures are getting executed before the form opens and I don't have a clue what order they are in. Due to the issue with single stepping, I don't know the order. Any suggestions you might have to help me follow the flow would be greatly appreciated.

Thanks.
0
 
ladarlingCommented:
Well, without seeing exactly how the form is created and instantiated, it could be a number of issues.
First, make sure that you set the MDI Child StartPosition to Manual
ChildForm.StartPosition = FormStartPosition.Manual
 
If you have an MDI parent form and you want to create another form with the identical size and location properties of a previously created child, you would use something to the effect of:
 The following example works exactly as you said it needs to (both size and position wise)
 

        Dim ChildForm As New Form1
        ChildForm.MdiParent = Me
        
        If Me.MdiChildren.Count > 0 Then
            ChildForm.StartPosition = FormStartPosition.Manual
            ChildForm.Size = Me.MdiChildren(0).Size
            ChildForm.Location = Me.MdiChildren(0).Location
        End If
        ChildForm.Show()

Open in new window

0
 
LeeLiamAuthor Commented:
That's perfect.

It's working fine now.

It's really funny. I actually have 11 forms. Four worked properly but 11 opened with a different size and location. All were set to StartPosition as WindowsDefaultBounds. When I changed them to Manual, they all worked correctly.

.NET continues to baffle me with its inconsistencies.

Thanks for your help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now