![]() |
Re: TStringGrid, wordwrap, 1zeilig sieht es blöd aus
Hallo,
OffsetRect bringt nix, es sieht so aus, also ob er in das if RowHeights[R]<=AGrid.DefaultRowHeight then nicht reingeht. Macht er aber, sagt mein Debugger. Naja, mal weiterbasteln. Heiko |
Re: TStringGrid, wordwrap, 1zeilig sieht es blöd aus
Hallo,
LÖSUNG
Delphi-Quellcode:
if RowHeights[R]<=AGrid.DefaultRowHeight then
begin DrawRect:= Rect; // das hier war es
Delphi-Quellcode:
procedure DrawSGCell(AGrid: TStringGrid; C, R : integer; Rect : TRect;
Style : TFontStyles; Wrap : boolean; Just : TAlignment; CanEdit : boolean); { draws formatted contents in string grid cell at col C, row R; Style is a set of fsBold, fsItalic, fsUnderline and fsStrikeOut; Wrap invokes word wrap for the cell's text; Just is taLeftJustify, taRightJustify or taCenter; if CanEdit false, cell will be given the background color of fixed cells; call this routine from grid's DrawCell event } var S : String; S2 : String; DrawRect : TRect; iAlign : Integer; begin iAlign:= dt_left; case Just of taCenter : iAlign:= dt_center; taRightJustify : iAlign:= dt_right; end; with AGrid, Canvas do begin { erase earlier contents from default drawing } if (R >= FixedRows) and (C >= FixedCols) and CanEdit then begin // Brush.Color:= AGrid.Brush.Color; end else begin Brush.Color:= FixedColor; end; FillRect(Rect); { get cell contents } S:= Cells[C, R]; if length(S) > 0 then begin (* original code, keine Ahnung, was das soll ??? *) S2:= S; (* case Just of taLeftJustify : S:= ' ' + S; taRightJustify : S:= S + ' '; end; *) { set font style } Font.Style:= Style; { copy of cell rectangle for text sizing } DrawRect:= Rect; if Wrap then begin { get size of text rectangle in DrawRect, with word wrap } DrawText(Handle, PChar(S2), length(S2), DrawRect, dt_calcrect or dt_wordbreak or iAlign); if (DrawRect.Bottom - DrawRect.Top) > RowHeights[R] then begin { cell word-wraps; increase row height } RowHeights[R]:= DrawRect.Bottom - DrawRect.Top; SetGridHeight(AGrid); end; if RowHeights[R]<=AGrid.DefaultRowHeight then begin DrawRect:= Rect; DrawText(Handle, PChar(S2), length(S2), DrawRect, dt_singleline or dt_vcenter // klappt nicht, steht auch so im SDK or iAlign); end else begin DrawText(Handle, PChar(S2), length(S2), DrawRect, dt_wordbreak or iAlign); end; end else begin { no word wrap } DrawText(Handle, PChar(S2), length(S2), DrawRect, dt_singleline or dt_vcenter or iAlign); end; { if Wrap then } end; { if length(S) > 0 then } { restore no font styles } Font.Style:= []; end; end; Puh !!! |
Re: TStringGrid, wordwrap, 1zeilig sieht es blöd aus
:thumb:
|
Re: TStringGrid, wordwrap, 1zeilig sieht es blöd aus
Hallo,
:cheers: jo, war schwer zu finden. Heiko |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz