Krefti
      
Beiträge: 164
Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
|
Verfasst: Mi 21.05.08 06:33
Guten Morgen zusammen!
ich weiß, dass es zu diesem Thema schon einiges gibt. Ich habe auch sachen gefunden, aber nun weiß ich nicht, wie genau ich sie einbinden und verwenden soll.
wenn ihr mir dabei helfen könntet, wäre das super!!
ich habe ein messgerät, von dem ich daten übertrage, die schreibe ich beim download in ein record und gleichzeitig in ein memofeld zur kontrolle, danach werden sie automatisch in ein stringgrid geschrieben.
hier mal der code zum Füllen des stringgrids
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:
| procedure TForm1.FillTableClick(Sender: TObject); var i, w, Sek, Min, Std, restM, restS : integer;
Zeit, sekAusgabe, minAusgabe, stdAusgabe : string;
x,y,z,s : double;
begin
sgTabelle.Cells[1,0] := 'X-Werte ' + inifWerte.Einheit; sgTabelle.Cells[2,0] := 'Y-Werte ' + inifWerte.Einheit; sgTabelle.Cells[3,0] := 'Z-Werte ' + inifWerte.Einheit; sgTabelle.Cells[4,0] := 'S-Werte ' + inifWerte.Einheit;
sgTabelle.RowCount := IAnzahl + 1;
Sek := Strtoint(MeineWerte[0].Sekunde); min := strtoint(MeineWerte[0].Minute); std := strtoint(MeineWerte[0].Stunde);
for w := 1 to IAnzahl do begin sgTabelle.Cells[0,w] := inttostr(w); end; w := 1; for I := IAnzahl downto 1 do begin
x := MeineWerte[i-1].XWert; y := MeineWerte[i-1].YWert; z := MeineWerte[i-1].ZWert; s := MeineWerte[i-1].SWert;
if inifWerte.Einheit = '[dB]' then begin
sgTabelle.Cells[1,w] := floattostr(x); sgTabelle.Cells[2,w] := floattostr(y); sgTabelle.Cells[3,w] := floattostr(z); sgTabelle.Cells[4,w] := floattostr(s); end;
if inifWerte.Einheit = '[m/s²]' then begin
x := power(10,x / 20) * 1E-6; x := round(x * 100000) / 100000;
sgTabelle.Cells[1,w] := floattostr(x); y := power(10,y / 20) * 1E-6; y := round(y * 100000) / 100000;
sgTabelle.Cells[2,w] := floattostr(y); z := power(10,z / 20) * 1E-6; z := round(z * 100000) / 100000;
sgTabelle.Cells[3,w] := floattostr(z); s := power(10,s / 20) * 1E-6; s := round(s * 100000) / 100000;
sgTabelle.Cells[4,w] := floattostr(s); end; w := w +1; end; for w := 1 to IAnzahl do begin if w > 1 then begin sek := sek + mit; if sek >= 60 then begin restM := Round(sek div 60); sek := sek Mod 60; min := min + restM; end;
if min >= 60 then begin restS := Round(min div 60); min := min mod 60; std := std + restS; end;
end; sekAusgabe := inttostr(sek); minAusgabe := inttostr(min); stdAusgabe := inttostr(std);
if strtoint(sekAusgabe) < 10 then begin sekAusgabe := '0'+sekausgabe; end;
if strtoint(minAusgabe) < 10 then begin minAusgabe := '0'+ minAusgabe; end; MeineWerte[w-1].Zeit := stdAusgabe + ':' + minAusgabe + ':' + sekAusgabe + ' ' + MeineWerte[w-1].Tag + '.' + MeineWerte[w-1].Monat + '.' + MeineWerte[w-1].Jahr;
sgTabelle.Cells[5,w] := MeineWerte[w-1].Zeit; end; sgTabelle.height := form1.Clientheight -80; b0 := 50; b := Form1.ClientWidth - getSystemMetrics(SM_CXHThumb)-b0; b := b - (sgTabelle.Colcount -2) * 2 ; sgTabelle.colwidths[0] := b0;
for I := 1 to 5 do begin sgTabelle.colwidths[i] := b div (sgTabelle.ColCount -1); end;
showmessage('Die Daten wurden erfolgreich vom HVM100 übernommmen!'); end; |
und jetzt mal der Quellcode, den ich im Internet gefunden habe:
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:
| procedure StringGridAlignment(Grid: TStringGrid; Rect: TRect; ACol, ARow: Integer; Alignment: TAlignment; LineBreak: Boolean); var TextOut: String; begin Grid.Canvas.FillRect(Rect); TextOut := Grid.Cells[ACol,ARow]; if LineBreak = false then begin if Alignment = taLeftJustify then DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)), Rect,DT_LEFT); if Alignment = taCenter then DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)), Rect,DT_CENTER); if Alignment = taRightJustify then DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)), Rect,DT_RIGHT); end else begin if Alignment = taLeftJustify then DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)), Rect,DT_LEFT+DT_WORDBREAK); if Alignment = taCenter then DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)), Rect, DT_CENTER+DT_WORDBREAK); if Alignment = taRightJustify then DrawText(Grid.Canvas.Handle, PChar(TextOut), StrLen(PChar(TextOut)), Rect, DT_RIGHT+DT_WORDBREAK); end; end;
procedure TForm1.StringGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin if ARow = 0 then StringGridAlignment(StringGrid, Rect, ACol, ARow, taLeftJustify, False);
if ARow = 1 then StringGridAlignment(StringGrid, Rect, ACol, ARow, taCenter, True);
if ARow > 1 then StringGridAlignment(StringGrid, Rect, ACol, ARow, taRightJustify, False); end; |
meine frage wäre jetzt:
was ist hier für was und wo muss ich das in meinen code einbinden, oder geht es auch einfacher???
danke schon mal!!
gruß krefti
|