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 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.
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.
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...
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.
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.
Marketing our skills - please participate in the survey and share your insights -
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.
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
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..
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.