1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142:
| unit sudoku;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormActivate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private public end;
TFeld = object feld: array [1..3,1..3] of TLabel; sichtbar: TLabel; hintergrund: TLabel; constructor init(pX,pY: integer); constructor erkenne; end;
var Form1: TForm1;
implementation
constructor TFeld.init(pX,pY: integer); var i,j: integer; begin hintergrund:= TLabel.Create(Form1); hintergrund.Parent:= Form1; hintergrund.Left:= pX; hintergrund.Top:= pY; hintergrund.Width:= 56; hintergrund.Height:= 56; hintergrund.Color:= clred;
sichtbar:= TLabel.Create(Form1); sichtbar.Parent:= Form1; sichtbar.Left:= pX+2; sichtbar.Top:= pY+2; sichtbar.Width:= 52; sichtbar.Height:= 52; sichtbar.Color:= clSilver; sichtbar.Alignment:= taCenter; sichtbar.AutoSize:= false; sichtbar.Font.Color:= clblue; sichtbar.Font.Size:= 30; sichtbar.Visible:= false; for i:= 1 to 3 do begin for j:= 1 to 3 do begin feld[i,j]:= TLabel.Create(Form1); feld[i,j].Parent:= Form1; feld[i,j].Color:= clSilver; feld[i,j].Width:= 16; feld[i,j].Height:= 16; feld[i,j].Left:= pX + i*18 - 18 + 2; feld[i,j].Top:= pY + j*18 - 18 + 2; feld[i,j].AutoSize:= false; feld[i,j].Alignment:= taCenter; feld[i,j].Font.Color:= clgray; feld[i,j].Caption:= IntToStr(j*3 - 3 + i); end; end; end;
{$R *.dfm}
var matrix: array [1..3,1..3] of array [1..3,1..3] of TFeld;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if key = 27 then self.Close; end;
procedure TForm1.FormActivate(Sender: TObject); var i,j,k,l: integer; neu: TLabel; begin for i:= 1 to 3 do for j:= 1 to 3 do for k:= 1 to 3 do for l:= 1 to 3 do matrix[i,j][k,l].init(i*190+k*60-230,j*190+l*60-230); end;
procedure TForm1.Button1Click(Sender: TObject); var F: textfile; s: string; i,j,k,l: integer; begin assignFile(f,'maps.txt'); reset(f);
for j:= 1 to 3 do begin for l:= 1 to 3 do begin readln(f,s); for i:= 1 to 3 do begin for k:= 1 to 3 do begin if s[i*3-3+k] <> '0' then begin matrix[i,j][k,l].sichtbar.BringToFront; matrix[i,j][k,l].sichtbar.Visible:= true; matrix[i,j][k,l].sichtbar.Caption:= s[i*3-3+k]; end; end; end; end; end;
end;
procedure TForm1.Button2Click(Sender: TObject); begin self.Close; end;
end. |