Scaleheight will give the entire height of the form, without allowing for Toolbars etc. What Randem requires is the useable area when all this is taken into account.
However, upon reflection it is obvious that a Toolbar has a height in Twips that is independent of Screen resolution. I.e. a toolbar that is 400 twips on my screen (1680 x 1050) will still be 400 twips on a 800 x 600 machine. So some number crunching here in the form should actually cater for all!
Are you sure? As far as I can tell they return the usable area. The Caption on the form below shows the returned Scalewidth and ScaleHeight properties.
I see that a normal form will take into account the menu, but not the toolbars wheras a MDI form will account for both
If you look at my jpg's, they all show the same scaleheight (and height) for -
A blank form
A form with a menu
A form with a menu and toolbar.
Of interest is the fact that an MDI form changes its height as Menu components are added, but not toolbars. You were right in post #3 though, that an MDI form does correctly return the required parameters in the Scaleheight property. Randem must be like me, hardly ever use MDI.
On a MDI form with toolbars and menus, how can one calculate the usable area (height) of the MDI form.
Usable means the area below the toolbar to the bottom of the form.
In form or screen co-ordinates?
You can calculate either by using a combination of the APIs GetWindowRect and GetClientRect. GetWindowRect returns the form size/position in screen co-ordinates. GetClientRect returns the size of the client area (below the menu bar) - which seems to be what you're after. Subtracting the client width from the window width gives you the form's border width/height x2. Once you have the border you can calculate the position of the client area top-left corner in either form or screen co-ordinates. GetClientRect will include the dimensions of any tool/status bars so you'll need to take this into account.
I do this for positioning overlays. Do yu have a specific problem in mind ?
Note: The GetTitleBarInfo API will not provide the information you require, neither will GetSystemMetrics nor SystemParametersInfo.
The problem I had was when using ListView controls on SSTAB containers. When the ListView had a heading the height of the listview changed and had to be recalculated to fit into the assigned area. Being that it was at the bottom of the screen all calculation to fit the controls overflowed the viewing area because of the change.
Thanks all it helped point me in the right direction.
Re: [RESOLVED] How to calculate usable screen area height
This problem also occurs if you place any object on the MDI form such as a picturebox. Even though you can display over the picturebox the usable area is decreased and that will mess up any sizing calculations based on the new reduced size even though the complete area of the MDI form is usable.
Re: [RESOLVED] How to calculate usable screen area height
The solution was to load the MDI form then get the usable area (ScaleWidth and ScaleHeight) then dynamically load the PictureBoxes that I needed as to not decrease the ScaleHeight that I held, then use the held ScaleHeight and ScaleWidth to calculate the remaining area that I had to move other controls around each Maximized loaded MDI Child form.