Jump to content


Photo

Bug in TNxMemoItemDisplay.PaintValueData;


  • Please log in to reply
1 reply to this topic

#1 Kevin Hall

Kevin Hall
  • Members
  • 1 posts

Posted 02 February 2009 - 01:08 AM


CODE

procedure TNxMemoItemDisplay.PaintValueData;
procedure DrawLines;
var
i: Integer;
r: TRect;
B: Graphics.TBitmap;
begin
r := GetTextRect;
B := Graphics.TBitmap.Create;
B.LoadFromResourceName(HInstance, 'NEWROW');
B.TransparentColor := clLime;
B.Transparent := True;
with Item as TNxMemoItem do
begin
for i := 0 to Lines.Count - 1 do
begin
DrawTextRect(Canvas, r, Lines[i]);
r.Left := r.Left + Canvas.TextWidth(Lines[i]) ;
if MultiLineSymbol and (i < Lines.Count - 1) then
begin
Canvas.Draw(r.Left, (r.Top + (r.Bottom - r.Top) div 2) - B.Height div 2, B ) ;
r.Left := r.Left + B.Width;
end;
r.Left := r.Left + 4;
if r.Left > ClientRect.Right then Exit; /// The "Exit" at this line keeps the bitmap from being freed
end;
end;
B.Free;
end;
begin
with Canvas do
begin
Font.Assign(Item.ValueFont);
if Item.Value = '' then
begin
Font.Color := clGrayText;
TGraphicsProvider.DrawTextRect(Canvas, GetTextRect, taLeftJustify, Item.EmptyValue, BiDiMode);
end else DrawLines;
end;
end;


/// change to this and the problem goes away
CODE

procedure TNxMemoItemDisplay.PaintValueData;
procedure DrawLines;
var
i: Integer;
r: TRect;
B: Graphics.TBitmap;
begin
r := GetTextRect;
B := Graphics.TBitmap.Create;
try /// added
B.LoadFromResourceName(HInstance, 'NEWROW');
B.TransparentColor := clLime;
B.Transparent := True;
with Item as TNxMemoItem do
begin
for i := 0 to Lines.Count - 1 do
begin
DrawTextRect(Canvas, r, Lines[i]);
r.Left := r.Left + Canvas.TextWidth(Lines[i]) ;
if MultiLineSymbol and (i < Lines.Count - 1) then
begin
Canvas.Draw(r.Left, (r.Top + (r.Bottom - r.Top) div 2) - B.Height div 2, B ) ;
r.Left := r.Left + B.Width;
end;
r.Left := r.Left + 4;
if r.Left > ClientRect.Right then Exit;
end;
end;
finally /// added
B.Free;
end; /// added
end;
begin
with Canvas do
begin
Font.Assign(Item.ValueFont);
if Item.Value = '' then
begin
Font.Color := clGrayText;
TGraphicsProvider.DrawTextRect(Canvas, GetTextRect, taLeftJustify, Item.EmptyValue, BiDiMode);
end else DrawLines;
end;
end;


#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 02 February 2009 - 05:27 PM

Hello,

Thank you, I will add your fix in official release.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users