Solved

Child window resize problem

Posted on 2008-10-10
5
332 Views
Last Modified: 2008-10-11
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
Comment
Question by:LeeLiam
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:ladarling
ID: 22690546
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
 
LVL 12

Expert Comment

by:rionroc
ID: 22690757
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
 

Author Comment

by:LeeLiam
ID: 22690887
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
 
LVL 11

Accepted Solution

by:
ladarling earned 500 total points
ID: 22691025
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
 

Author Comment

by:LeeLiam
ID: 22694990
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now