The listed problems are NOT problems with Inprise's Delphi, they are the challenges of programming for a wide range of monitor resolutions for shrink wrapped applications.
General Resolution Tips:
I had a frustrating time to have my applications appear more or less like I had designed them on the various monitor resolutions that are on the market.
Some of the things that did not display properly were;
Labels had text cut of at the bottom or at the end. Grids showed white space between the last column and the vertical scroll bar. Other times I used more real estate then was available on the customers computer.The list below shows what works well for me.
Problem experienced with Grids:
- Program in the lowest resolution users might use
- Set monitor to use large fonts
- Set the forms scaled property to FALSE
- Set the Auto Size property for Edits and Labels to FALSE
- Use Basic fonts like MS Sans Serif for Labels and Edits (Avoid True Type Fonts) unless you know they exist on the destination Computer
- Make all Edits, Labels etc. 25% wider then needed
- Make all Labels 30% higher then needed
- Place groups of components on Panels (Helps to get things aligned quickly when)
- Use TSpliter componts so user can re-size panels
String Grids and DBGrids show a white border between the last column and the vertical scroll bar.
Solution Code: (D2, D3, for D4 see special note)
Call this procedure on the forms Create or Activate Event.
procedure SizeGrid;
Var
GridTotalWidth :Integer; //Holds the total width of the columns plus the separator line
ColumnIndex :Byte; //Holds the Column Index
begin
GridTotalWidth :=12; // The DBGrids indicator is 12 pixels in width (can also use API call to get the indicators width)//Iterate through all the columns of the Grid
For ColumnIndex := 0 to DBGrid1.Columns.Count -1do
begin
//Add the current columns width to the GridTotalWidth variable, add 1 for the thickness of the
divider line
GridTotalWidth := GridTotalWidth + DBGrid1.Columns[ColumnIndex].Width +1;
end; //Assign the GridTotalWidth Variable to the Grids Client Width
DBGrid1.ClientWidth := GridTotalWidth;
end;In D2 and D3 the Grid automatically adds the width of the vertical scroll bar.
D4 Special Note:
In Delphi 4 the Grid wont automatically be correctly sized by assigning the GridTotalWidth variable to its client width. I don't know if this is a feature or a bug :) ?
D4 also has a line thickness property that you need to use instead of just adding 1 to the width for each column.To figure out the vertical scroll bars thickness, use the GetSystemMetrics API Call.
Initially assign 0 to the GridTotalWidth Variable, at the location in the code where I assigned 12.
Replacing the last line of code from the procedure above with the one here.
DBGrid1.Width := GridTotalWidth + GetSystemMetrics(SM_CXVSCROLL);
E-mail: