procedure TMainFrm.GridOnCreate(Sender: TObject); // called by FormCreate
var
i,j: Integer;
begin
PostPts.RowCount:= 101;
PostPts.ColCount:= 6;
PostPts.colwidths[0]:= 60; {point}
PostPts.colwidths[1]:= 128; {north}
PostPts.colwidths[2]:= 128; {east}
PostPts.colwidths[3]:= 90; {grade}
PostPts.colwidths[4]:= 220; {text}
for i:=0 to PostPts.ColCount-1 do
begin
// alternatively to... PostPts.Cells[i, 0]:= 'Col'+IntToStr(i);
// with the below the title cells are posted, and the cell data is populated later
case i of
0: PostPts.Cells[i,0]:= ' Point';
1: PostPts.Cells[i,0]:= ' North';
2: PostPts.Cells[i,0]:= ' East';
3: PostPts.Cells[i,0]:= ' Grade';
4: PostPts.Cells[i,0]:= ' Text';
end;
for j:=1 to PostPts.RowCount-1 do
PostPts.Cells[i,j] := ' ';
end;
FOrigWidth:= PostPts.Width;
//FOrigFontHeight := GetFontData(PostPts.Font.Handle).Height; // handled by ScaleDPI in FormActivate
SetLength(FOrigColWidths, PostPts.ColCount);
SetLength(FOrigRowHeights, PostPts.RowCount);
for i:= 0 to High(FOrigColWidths) do
FOrigColWidths[i]:= PostPts.ColWidths[i];
for i:= 0 to High(FOrigRowHeights) do
FOrigRowHeights[i]:= PostPts.RowHeights[i];
end;
procedure TMainFrm.GridOnActivate(Sender: TObject); // called by FormActivate
var
factor: Double;
i: Integer;
s: string;
begin
{$IFDEF WINDOWS}
if WindowsVersion = wvLater // Win10 // uses win32proc ... wvXP wvVista wv7 wv8 wvLater
then begin
factor:= PostPts.Width / FOrigWidth;
//str(VertScrollbar.Size,s);
//showmessage('Win10 bar='+s);
end;
if WindowsVersion = wv8 // Win8 // uses win32proc ... wvXP wvVista wv7 wv8 wvLater
then begin
factor:= PostPts.Width / FOrigWidth;
//str(VertScrollbar.Size,s);
//showmessage('Win8 bar='+s);
end;
if WindowsVersion = wv7 // Win7 // uses win32proc ... wvXP wvVista wv7 wv8 wvLater
then begin
factor:= PostPts.Width / FOrigWidth;
//showmessage('Win7');
end;
if WindowsVersion = wvVista // Vista // uses win32proc ... wvXP wvVista wv7 wv8 wvLater
then begin
factor:= PostPts.Width / FOrigWidth;
//showmessage('WinVista');
end;
if WindowsVersion = wvXP // WinXP // uses win32proc ... wvXP wvVista wv7 wv8 wvLater
then begin
factor:= (PostPts.Width - VertScrollbar.Size) / (FOrigWidth - VertScrollbar.Size);
//str(VertScrollbar.Size,s);
//showmessage('WinXP bar='+s);
end;
{$ELSE}
begin
factor:= (PostPts.Width - VertScrollbar.Size) / (FOrigWidth - VertScrollbar.Size);
//showmessage('Other');
end;
{$ENDIF}
for i:= 0 to PostPts.ColCount-1 do
PostPts.ColWidths[i]:= round(factor * FOrigColWidths[i]);
for i:= 0 to PostPts.RowCount-1 do
PostPts.RowHeights[i]:= round(factor * FOrigRowHeights[i]);
//PostPts.Font.Height := round(factor * FOrigFontHeight); // handled by ScaleDPI in FormActivate
end;