Strange behaviour of form
I have a form called FrmTest. In the properties of the form I have Height = 9000 and Width = 12000.
When the form displays it's bigger than it should be!
Code:
Debug.Print Me.Height
Debug.Print Me.Width
reports the height as 9300 and not 9000 as it should be :eek: The width is 12000 which is correct.
Adding:
Code:
Me.Height = 9000
Me.Width = 12000
in the Form_Load event displays the form the correct size.
Any ideas why this is happening? My program has about 20 forms, all the same size, and this is the only one that's giving me this hassle. It's not a huge issue as it can be corrected in code, just want to know why this is happening.
Re: Strange behaviour of form
If the form starts out the right size, then it sounds like the form is being resized somewhere in code.
Re: Strange behaviour of form
The only place where the form is referenced is in the CmdTest_Click() event where it says FrmTest.Show. Nowhere else in the code if there any reference to the FrmTest form.
In the code of the FrmTest form there is the references to Me.Height and Me.Width in the Debug.Print statements as shown above which shows the incorrect height of the form as 9300 instead of the correct 9000.
And there is the Unload Me statement in the CmdExit_Click() event to close the form.
Re: Strange behaviour of form
To really find out what's happening... step through your program with F8. See what's happening in the Resize event of your Form.
Re: Strange behaviour of form
It may depend on the resolution of your screen at start up.
Re: Strange behaviour of form
I've seen something like this once in one of my apps.
I set the Width and Height in the Properties Window. A while later I set the BorderStyle to something else, then that influenced the Form's Height and Width.
So, if I changed the BorderStyle to Fixed ToolWindow, the Form's height was changed to 8850 and so on.
I don't know if this post was helpful, but perhaps there is just a property that is set in this form's Properties, which isn't set on any other form...
Re: Strange behaviour of form
Menu''s and toolstrips also affect the size of the form ... if your adding either during runtime it may affect your form size...
Gremmy...
Re: Strange behaviour of form
Hi Guys
The borderstyles etc. is exactly the same as all other forms. This form has a hidden menu though as do some of the other forms. It's used for popup menus on the forms. This might be the reason for this behaviour. I remember when I created the menu I forgot to set it as invisible at first so it moved the rest of the form down. It was then later set as invisible so this could be the problem.
I'll remove it and see if that makes a difference.
Re: Strange behaviour of form
By any chance is the ScaleHeight giving the right size?
Re: Strange behaviour of form
What I have in mind is the snapping to grid during development. When you insert a code to set the dimension you want, it is corrected --- but by the time you edit it, it snap back to grid and if you omit the code to correct it, the 'snapped' dimensions remain. Not sure though -- It's been more than 5 years I haven't touched VB6.
Re: Strange behaviour of form
No, the Form size does NOT snap to grid in the IDE.
I'd also think it has to do with the BorderStyle and menus. There is an issue when the Form has the titlebar and menus, its height is not correct.
The open question seems to be: what is the difference to the other forms which show correct behaviour.
Re: Strange behaviour of form
It definitely has to do with the menu. I created another form and added the menu items one at a time. The menu item looked like this (name and settings in brackets):
Parent (mnuParent, invisible)
Sorting (mnuSorting, invisible)
....on ID number (mnuSort, Index 1, visible)
....on First Name (mnuSort, Index 2, visible)
....on Last Name (mnuSort, Index 3, visible)
....- (mnuSort, Index 4, visible)
....Exit Menu (mnuSort, Index 5, visible)
Saving (mnuSaving, invisible)
....Save to Temporary File (mnuSave, Index 1, visible)
....Restore from Temporary File (mnuSave, Index 2, visible)
....- (mnuSave, Index 3, visible)
....Delete Temporary File (mnuSave, Index 4, visible)
....- (mnuSave, Index 5, visible)
....Exit Menu (mnuSave, Index 6, visible)
The sub items under Sorting is used for one popup menu and the sub items under Saving is used for a second popup menu.
Up to the first Exit Menu (mnuSort, Index 5) menu item the form size is 100% :) When the Saving (mnuSaving) menu item was added the form size (height) grew with 300 from 9000 to 9300 :confused:
Re: Strange behaviour of form
Do us a favour...
Zip and post that form that does this.. (the new one you made will do) .. so that we can check how and why ...
I will spend some time over the weekend (have VB6 only on Home System, not at work) and see if i can find something...
Gremmy..
1 Attachment(s)
Re: Strange behaviour of form
Hope the attachment works.
You'll see if you remove the last menu entry named Saving the size is correct but with it there the size is 300 more than it should be.
1 Attachment(s)
Re: Strange behaviour of form
Well I tested the form you posted, and as best as i could find on my system everything was working as expected..The form stayed at exactly the right size, no matter how many items i added to the list..
I'd say try rebooting the system, or perhaps carefully adding everything to a new project..
Attached is the same form with items that i've added and a few changes so that i could see what's happening..
there's obviously something else, related to the menu's, affecting the form..
Gremmy...
Re: Strange behaviour of form
Been a long while since I did anything in VB6. However, if you are just using the menu for a popup menu, try the code from this thread. It uses the API so you shouldn't have an issue with the size of the form.
http://www.codeguru.com/forum/showth...95#post1280395
1 Attachment(s)
Re: Strange behaviour of form
Hi Gremmy
I've removed the menu items you added so that the menu is the same as it was when I send it the first time. If you run it you will see the form height is reported as 9300 while it is set in the form properties as 9000 (or 300 more than is set in the properties if another size is set there)
If you now delete the last entry in the menu named mnuSaving (Saving) and you run it again you will see that the form height is reported as 9000, the same as set in the form properties.
As I said initially, it's not a huge problem as it can be 'fixed' by setting the form height in the Form_Load event and it will display correctly. I just found it to be strange behaviour.
Re: Strange behaviour of form
Everything works fine for me :eek: :confused:
Have you considered redsigning the form, IOW, add a new form and add all the necessary controls to it, and then test it ¿
Re: Strange behaviour of form
Well in playing around with it, i cant replicate the problem..
I'm almost sure that it's a problem with your system or install, and not so much with VB6..
1 Attachment(s)
Re: Strange behaviour of form
Narrowed the problem down to a combination of the menu and form StartUpPosition property.
Attached is the same project now with three forms.
FormA has the menu and StartUpPosition is set to CenterOwner - height incorrect at 9300.
FormB has exactly the same menu and StartUpPosition is set to WindowsDefault - height correct at 9000.
FormC has the menu with one less menu item and StartUpPosition set to CenterOwner as in FormA - height correct at 9000
Re: Strange behaviour of form
Take out the Crystal Report Reference that you have in there and see if that makes a difference. I couldn't test it on Vista 64bit
Re: Strange behaviour of form
The form is always the correct size for me as well. Do you have windows xp "themes" enabled within VB, or for the app? The default xp theme has a large TitleBar - might that account for the extra pixels?
If you want the form to be full screen, can you not set the WindowState property to 2 - Maximized?
Re: Strange behaviour of form
David
Removed all the references and still the same on my system.
WizBang
No themes or such. I want the form to be the 9000 x 12000 that I specified. All my forms is designed around that size.
So it seems the problem is only on my system. Thanks in any case guys, I'll just get around it by setting the height in the form load event.