diff --git a/applications/sudoku/sudokumain.lfm b/applications/sudoku/sudokumain.lfm index c85cf736a..723a92c6e 100644 --- a/applications/sudoku/sudokumain.lfm +++ b/applications/sudoku/sudokumain.lfm @@ -31,7 +31,7 @@ object Form1: TForm1 Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll] RowCount = 9 TabOrder = 2 - OnDrawCell = StringGrid1DrawCell + OnPrepareCanvas = StringGrid1PrepareCanvas OnSetEditText = StringGrid1SetEditText end object ButtonFill: TButton diff --git a/applications/sudoku/sudokumain.pas b/applications/sudoku/sudokumain.pas index 38c8aaa5a..12eeb8ae7 100644 --- a/applications/sudoku/sudokumain.pas +++ b/applications/sudoku/sudokumain.pas @@ -41,8 +41,8 @@ type StringGrid1: TStringGrid; procedure ButtonFillClick(Sender: TObject); procedure ButtonSolveClick(Sender: TObject); - procedure StringGrid1DrawCell(Sender: TObject; Col, Row: Integer; - aRect: TRect; aState: TGridDrawState); + procedure StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer; + aState: TGridDrawState); procedure StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer; const Value: string); private @@ -89,31 +89,29 @@ begin end; end; -procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col, Row: Integer; - aRect: TRect; aState: TGridDrawState); + +procedure TForm1.StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer; + aState: TGridDrawState); var - Kleur: Boolean; + NeedsColor: Boolean; begin - Kleur := False; - if Col in [0..2, 6..8] then begin - if Row in [0..2, 6..8] then begin - Kleur := True; + NeedsColor := False; + if aCol in [0..2, 6..8] then + begin + if aRow in [0..2, 6..8] then + begin + NeedsColor := True; end; - end else begin - if Row in [3..5] then begin - Kleur := True; + end + else + begin + if aRow in [3..5] then + begin + NeedsColor := True; end; end; - if Kleur then begin - inc(aRect.Top, 1); - inc(aRect.Left, 1); - dec(aRect.Bottom, 1); - dec(aRect.Right, 1); - StringGrid1.Canvas.Brush.Color := clLtGray; - StringGrid1.Canvas.FillRect(aRect); -// Volgende regel is alleen in Delphi noodzakelijk. -// StringGrid1.Canvas.TextOut(aRect.Left, aRect.Top, StringGrid1.Cells[Col, Row]); - end; + if NeedsColor then + (Sender as TStringGrid).Canvas.Brush.Color := $00EEEEEE; end; procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;