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:
| unit frm_sensorentest;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, Buttons, StdCtrls, Grids;
type TTor = Array[0..9,0..24] of byte;
type TSensortest = class(TForm) // StringGrid1: TStringGrid; Label2: TLabel; Label4: TLabel; Label6: TLabel; SpeedButton1: TSpeedButton; Button1: TButton; procedure Button1Click(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); procedure FormCreate(Sender: TObject); private { Private declarations } Tor: TTor; StringGrid1: TStringGrid; public { Public declarations } end;
var Sensortest: TSensortest; // tor : array [0..24]of array [0..10] of TTorDaten;
implementation
{$R *.dfm}
uses Main;
procedure TSensortest.Button1Click(Sender: TObject); begin close; end;
procedure TSensortest.FormCreate(Sender: TObject); //var //aCol,aRow: SmallInt; begin // ColorField mit 0 vorbelegen FillChar(Tor,SizeOf(Tor),0); // Eingabe und Tabulator im Grid zulassen StringGrid1.Options:= StringGrid1.Options + [goTabs, goEditing]; end;
procedure TSensortest.SpeedButton1Click(Sender: TObject); var aCol,aRow: SmallInt; begin // Muster bestehen aus 1 und 2 in ColorField generieren for aRow:= 0 to 24 do for aCol:= 0 to 9 do if ((aRow+aCol) mod 2)= 0 then Tor[aCol,aRow]:= 1 else Tor[aCol,aRow]:= 2;
// Neuzeichnen des Grids veranlassen StringGrid1.Repaint; end;
procedure TSensortest.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var Farbe: byte; TextToShow: String; begin // wenn fixierte Zelle, dann kein umfärben notwendig if gdFixed in State then Exit;
with sender as TStringGrid do begin // Farbe aus ColorField wählen Farbe:= Tor[aCol,aRow]; // Text in Zelle merken TextToShow:= Cells[aCol,aRow]; // Malfarbe auf weiss stellen Canvas.Brush.Color:= clWhite; // wenn Eintrag in ColorField 1 oder 2, dann Farbe // auswählen case Farbe of 1: Canvas.Brush.Color:= clRed; 2: Canvas.Brush.Color:= clGreen; end; // Bereich Rect einfärben Canvas.FillRect(Rect); // zwischengespeicherten Text ausgeben Canvas.TextOut(Rect.Left+2, Rect.Top+2, TextToShow); end; end;
end. |