Forms inaccuratly calculate size

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I have a fairly straight-forward form that loads preferences upon
running, and saves them upon exiting. Included in the preferences are
things like window size & location, working directory, etc. There
seems to be a problem with the way the size of the form is being
calculated. If you run/exit/run/exit a bunch of times, the form keeps
growing vertically. This is because it looks like the forms Menu is
not being included into the size calculation. For example, if you set
the size programatically to 640x480, when the form displays, it adds in
19 vertical pixels for the menu to make the size 640x499. Then the
prefs write out, then on next load, the size is 640x518...and so on.

Subtracting the height of the menu when writing out the preferences
seems like the obvious answer, but it seems kludge-y, as the user might
have large fonts or something that will make a hard-coded subtract 19 a
bad idea. As far as I can tell, there isn't an easy way to tell the
height of a Menu object.

Has anyone run into this, or have a good solution for dynamically
calculating the height of a menu?

Thanks,
Chris
 
Chris said:
Has anyone run into this, or have a good solution for dynamically
calculating the height of a menu?

Not sure, but you might try writing/saving Form.ClientSize instead of
Form.Size. I would think that ClientSize wouldn't include the size of any
menus.
 
I tried clientsize too. Actually, I tried all of the obvious ones,
Size, ClientSize, DesktopBounds and all of them do the same thing, and
only vertically. Removing the menu from the window altogether stops
this from happening.
 
Back
Top