all groups > vb.net upgrade > october 2003 >
You're in the

vb.net upgrade

group:

Form Size Mystery


Form Size Mystery Darrell Wesley
10/22/2003 6:27:37 AM
vb.net upgrade:
I have a VB6 application that has run thru the conversion
process to VB .net. All compile time and run time errors
have been cleaned up and the application does run.

One puzzle remains to be solved. The application uses an
MDI form as well as 3 child forms which may or may not be
all on screen at once. In the primary child form's
properties I have the Height set at 544 and Width at 552,
I even set the Height and Width in that forms load routine
but when it becomes active it has completely different
values like 478 and 800.

I have searched for where the height and width may being
used but have come up empty handed. No place in code can I
find these being set. Is there someplace else to look?

The properties are set at 544 and 552 for Height and
Width. Just before the show method is used in the MDI form
these values are 537 and 768, in the load routine they are
set to 555 and 541 but when activated they are 478 and
800. Where can they possibly being set to something on
there own?


RE: Form Size Mystery Darrell Wesley
10/22/2003 2:37:14 PM
The problem is with one of the child forms. The only place
where the SIZE is being set is either in the Design time
properties or in the load event of the child form.

The ControlBox property is set to TRUE for both the MDI
parent and the child.

The Startup form for this project is the Child form. If I
choose to start with the MDI parent form I get sometype of
reentrant or recursive call to the parent form which .net
does not like but more on that later.

Remember this is a VB6 program that has been run through
the convert routine. The VB6 compatablilty layer it throws
in may be at issue here. I know that it sets up some type
of default instance of the form but I don't see any
reference to height or width at that point.

Will post sample code if needed.
[quoted text, click to view]
RE: Form Size Mystery JohnHart NO[at]SPAM Online.Microsoft.com.
10/22/2003 6:56:52 PM
Hi Darrel,

There was a post fairly simular to this here recently. It's not perfectly
clear to me from your post if this is the MDI form or the child forms that
are having the problem. Either way are you setting the location property of
these forms prior to the form load? If so try moving this to the form's
load event instead. The other example of this problem that I saw was
related to the form's location being setting prior to the load and the
control box property being set to False at design time. For some reason
this was causing the form's size calculation to be off and it appears
something simular is happening with your project.

Let me know if this helps. If not if you could provide some a code sample
of how your showing the child form's I'll be glad to look into it further.

--
John Hart, Microsoft VB Team
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
[quoted text, click to view]
RE: Form Size Mystery Darrell Wesley
10/23/2003 2:07:45 PM
The pixeltotwips conversion has been commented out and
the .net values inserted so I don't think that is the
cause.

You keep saying "location" , this problem child form is
not having it's location set except in the design time
properties. I have noticed that instead of the top left
corner of this form being in the top left corner of the
MDI container it is offset - I even tried to set these to
0 and 0 and had no effect on the outcome.

I will zip up the entire assembly and send it to you.
Maybe you can see something I don't.

Thanks for the help so far.
Darrell
[quoted text, click to view]
RE: Form Size Mystery JohnHart NO[at]SPAM Online.Microsoft.com.
10/23/2003 6:28:16 PM
I don't intially expect the compatbility library as the problem here. It
may be that the upgrade is over using the pixeltotwips conversion but I
would expect you would see that in more then just the one form. I didn't
see that you answered my question though, are you setting the problem Child
form's Location prior to it being shown?

If you could post some code that would be helpful or you can send a repro
to me at VBResult@microsoft.com and I'll be glad to take a look

--
John Hart, Microsoft VB Team
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
[quoted text, click to view]
RE: Form Size Mystery JohnHart NO[at]SPAM Online.Microsoft.com.
10/24/2003 10:12:13 PM
Thanks Darrel for sending me the project. It really helped to understand
the problem.


The problem with the MDI Child form being a different size then you set at
design time was due to the StartupPosition property. The form's
StartupPostion was set to WindowsDefaultBounds and should have been set to
WindowsDefaultLocation.

Here's the help topic that explains the differences:

WindowsDefaultBounds The form is positioned at the Windows default location
and has the bounds determined by Windows default.
WindowsDefaultLocation The form is positioned at the Windows default
location and has the dimensions specified in the form's size.

The other problem that you mentioned with the MDIForm being the Startup
object and it causing an overflow was being caused by your call to Sub
Main() in the MDI Form_Load event. What was happening is this call was
actually calling the hidden Sub Main that was inserted in the form by the
compiler since it was the startup object so instead of calling the sub Main
in your Globals.vb file you were calling Sub Main on the form over and over
and over. To fix the problem I just following qualified the call so it
should be Globals_Rename.Main(). This fixed that problem.

--
John Hart, Microsoft VB Team
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
[quoted text, click to view]
<jdIBI5MmDHA.2464@cpmsftngxa06.phx.gbl>
<04b901c398e4$a8930a40$a301280a@phx.gbl>
<qTUltNZmDHA.1804@cpmsftngxa06.phx.gbl>
[quoted text, click to view]
AddThis Social Bookmark Button