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:
| unit CataUnit;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Inifiles, Grids;
type TForm1 = class(TForm) StringGrid1: TStringGrid; procedure FormCreate(Sender: TObject); procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); private public end;
var Form1: TForm1; Spalte,Zeile,Alth:Integer; markiert:boolean;
implementation
{$R *.dfm}
procedure markieren(grd:TStringgrid;i,h:integer); begin grd.Canvas.FillRect(grd.CellRect(i,h)); grd.Canvas.TextOut(grd.CellRect(i,h).Left+2,grd.CellRect(i,h).Top+2,grd.Cells[i,h]); end;
Procedure CellMark(grd:TStringGrid;h:integer); var oldbrush: TBrush; i:integer; begin if Markiert then Begin for i:=1 to 6 do Begin with grd.Canvas do begin oldbrush:=brush; brush.Color:=clcream; font.Color:=clBlack; grd.Canvas.FillRect(grd.CellRect(i,alth)); grd.Canvas.TextOut(grd.CellRect(i,alth).Left+2,grd.CellRect(i,alth).Top+2,grd.Cells[i,alth]); brush:=oldbrush; end; end; markiert:=false; end; for i:=1 to 6 do Begin with grd.Canvas do begin oldbrush:=brush; brush.Color:=clred; grd.Canvas.FillRect(grd.CellRect(i,h)); grd.Canvas.TextOut(grd.CellRect(i,h).Left+2,grd.CellRect(i,h).Top+2,grd.Cells[i,h]);
brush:=oldbrush; grd.Update; end; end; Alth:=h; markiert:=true; end;
procedure TForm1.FormCreate(Sender: TObject); var Ini:Tinifile; i:integer; begin ini:=Tinifile.Create(Extractfilepath(Paramstr(0))+'Fragen.ini'); Stringgrid1.RowCount:=Ini.ReadInteger('Anzahl','Anz',1)+1; Stringgrid1.Cells[1,0]:='Frage'; stringgrid1.Cells[2,0]:='Antwort 1'; stringgrid1.Cells[3,0]:='Antwort 2'; stringgrid1.Cells[4,0]:='Antwort 3'; stringgrid1.Cells[5,0]:='Antwort 4'; Stringgrid1.Cells[6,0]:='richtig'; for i:=1 to Stringgrid1.Rowcount-1 do Stringgrid1.Cells[0,i]:=IntToStr(i); for i:=1 to Stringgrid1.Rowcount-1 do Stringgrid1.Cells[1,i]:=Ini.ReadString('Fragen',IntToStr(i),'keine Frage'); for i:=1 to Stringgrid1.Rowcount-1 do Stringgrid1.Cells[2,i]:=Ini.ReadString('Antwort1',IntToStr(i),'keine Antwort'); for i:=1 to Stringgrid1.Rowcount-1 do Stringgrid1.Cells[3,i]:=Ini.ReadString('Antwort2',IntToStr(i),'keine Antwort'); for i:=1 to Stringgrid1.Rowcount-1 do Stringgrid1.Cells[4,i]:=Ini.ReadString('Antwort3',IntToStr(i),'keine Antwort'); for i:=1 to Stringgrid1.Rowcount-1 do Stringgrid1.Cells[5,i]:=Ini.ReadString('Antwort4',IntToStr(i),'keine Antwort'); for i:=1 to Stringgrid1.Rowcount-1 do Stringgrid1.Cells[6,i]:=Ini.ReadString('richtig',IntToStr(i),'keine Antwort'); markiert:=false; end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin Zeile:=StringGrid1.Row; Spalte:=StringGrid1.Col; Cellmark(Stringgrid1,Zeile); end;
end. |