Form.Height depending on Windows style?

R

Rune Jacobsen

Hi all,

I have an application with one particular form that lists a number of
items in a listview. In addition to the listview, there is a panel on
top with some simple controls to go back and forth to the next and
previous day.

Since the number of items in the list can vary from day to day - from
zero one day to thirty another, and five the third - my users like the
option to have the Window resize itself to exactly fit the number of
items. That way, no space is wasted on "short" days, and you don't have
to scroll up and down for the "longer" days.

I thought that when I use this.Height to get the form height, this would
represent the height of everything inside the window borders. So since
my listview has dock set to Fill, I thought I could basically subtract
the list height from the form height to get the "rest" height for
everything but the list, then add that to (listviewitem.height*items +
X) (where X is the size of the listview stuff apart from the items, that
I can figure out at compile time) to get the new form height.

And this works fine on my own computer, running Windows XP with the
"Windows Classic" style. However, it doesn't work at all on WinXP with
the "rounded" XP style. So, what gives? Is the internal form size
dependant on the window border size, or what?

Am I completely wrong in assuming that in a layout like this, with a
panel (top docked) and a listview, the form height would basically be

panel.Height + listview.Height == form.Height

- or is this wrong?

I know about SystemInformation.CaptionHeight and
SystemInformation.BorderSize.Height, but I would really think that my
form size should be independent of this?

Does anyone know a good "formula" for calculating this, that is
completely independent of the window decorations? I expect that there
are other "skins" and such for Windows that can alter these things
further and really makes it necessary to find a "neutral" way to
calculate this.

Any insight will be highly appreciated!

Thanks,

Rune
 
K

krishna.bitla

Hi Rune,

If the problem is with the screen resolution of the user computers,
identify the screen resolution and have a display class to change your
controls location based on the user settings.

Cheers,
Kris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top