TPrintPreview drawText problem

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

TPrintPreview drawText problem

Postby john12345 » October 13th, 2017, 7:15 am

Hello,
Recently, I have encountered the TPrintPreview problem with "canvas.drawText".
When I set the alignment to the right "DT_RIGTH" the text does not fit in the rectangle.

simple example:
preview.drawText (canvas.handle, 'test test test', -1, r, DT_RIGHT);

Please advise.
Piotr
Attachments
Bez tytułu.jpg
Bez tytułu.jpg (4.17 KiB) Viewed 3159 times
john12345
Member
Member
 
Posts: 2
Joined: October 12th, 2017, 10:35 am

Re: TPrintPreview drawText problem

Postby john12345 » October 13th, 2017, 8:16 am

The problem exists when set mmLoMetric in units.
john12345
Member
Member
 
Posts: 2
Joined: October 12th, 2017, 10:35 am

Re: TPrintPreview drawText problem

Postby dstu » December 1st, 2017, 11:06 am

Hallo, try this:
with PrintPreview.Canvas do begin
Brush.Color:=Base.FuellFarbe;
Brush.Style:=bsClear;
Font.Color:=Base.LinienFarbe;
Font.Size:=Base.FontSize;
Font.Name:=Base.FontName;
Font.Style:=Base.FontStyle;
rc:=Bounds(Base.X,Base.Y+Offset,Base.Width,Base.Height);
if Base.Align = DT_Right then begin
rc.Left:=rc.Right - TextWidth(s) - 10;
DrawText(Handle,PChar(String(s)),length(s),rc,DT_Left+DT_NOPREFIX);
end else DrawText(Handle,PChar(String(s)),length(s),rc,Base.Align+DT_NOPREFIX);
end;
best regards dstu
dstu
Member
Member
 
Posts: 1
Joined: December 1st, 2017, 10:30 am


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 29 guests

cron