Sudoku: adjust width/height of grid, and width of mainform @runtime.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7226 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
lazarus-bart
2020-01-04 16:37:48 +00:00
parent b974c2145b
commit a95b456fb5
3 changed files with 11 additions and 0 deletions

View File

@ -49,6 +49,7 @@
<Unit2>
<Filename Value="sudokutype.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="SudokuType"/>
</Unit2>
</Units>
</ProjectOptions>

View File

@ -9,6 +9,7 @@ object Form1: TForm1
Caption = 'Form1'
ClientHeight = 359
ClientWidth = 333
OnActivate = FormActivate
LCLVersion = '2.1.0.0'
object StringGrid1: TStringGrid
Left = 16
@ -22,6 +23,7 @@ object Form1: TForm1
FixedRows = 0
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
RowCount = 9
ScrollBars = ssNone
TabOrder = 2
OnPrepareCanvas = StringGrid1PrepareCanvas
OnSetEditText = StringGrid1SetEditText

View File

@ -43,6 +43,7 @@ type
StringGrid1: TStringGrid;
procedure ButtonFillClick(Sender: TObject);
procedure ButtonSolveClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer;
{%H-}aState: TGridDrawState);
procedure StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
@ -83,6 +84,13 @@ begin
ShowSolution;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
Self.OnActivate := nil;
StringGrid1.ClientWidth := 9 * StringGrid1.DefaultColWidth;
StringGrid1.ClientHeight := 9 * StringGrid1.DefaultRowHeight;
ClientWidth := 2 * StringGrid1.Left + StringGrid1.Width;
end;
procedure TForm1.StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer;
aState: TGridDrawState);