Solved

Child window resize problem

Posted on 2008-10-10
5
368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

737 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