CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Join Date
    Sep 2001
    Location
    South Africa
    Posts
    186

    Question 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 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.

  2. #2
    Join Date
    Dec 2001
    Posts
    6,332

    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.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  3. #3
    Join Date
    Sep 2001
    Location
    South Africa
    Posts
    186

    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.

  4. #4
    Join Date
    Dec 2008
    Posts
    19

    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Strange behaviour of form

    It may depend on the resolution of your screen at start up.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    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...

  7. #7
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    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...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  8. #8
    Join Date
    Sep 2001
    Location
    South Africa
    Posts
    186

    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.

  9. #9
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Strange behaviour of form

    By any chance is the ScaleHeight giving the right size?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  10. #10
    Join Date
    Feb 2002
    Location
    Makati City, Philippines
    Posts
    1,054

    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.
    Marketing our skills - please participate in the survey and share your insights
    -

  11. #11
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    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.

  12. #12
    Join Date
    Sep 2001
    Location
    South Africa
    Posts
    186

    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

  13. #13
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    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..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  14. #14
    Join Date
    Sep 2001
    Location
    South Africa
    Posts
    186

    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.
    Attached Files Attached Files

  15. #15
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    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...
    Attached Files Attached Files
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured