xe3 c++ buider下 fmx打印报错,而拿delphi写就没问题,求解
C++ builder下
TRectF MyRect;
int x1, y1, x2, y2;
TPrinter *printer = Printer;
String s = "打印测试!";
// if(PrintDialog1->Execute() ) {
printer->Refresh();
printer->ActivePrinter->SelectDPI(100, 100);
// prn->ActivePrinter->ActiveDPIIndex = 1;
printer->Canvas->Font->Size = 15;
printer->Canvas->Font->Family = "Arial";
Printer->Canvas->Fill->Color = claBlack;
Printer->Canvas->Fill->Kind = TBrushKind(1);
printer->BeginDoc();
x1 = 10;
y1 = 10;
x2 = x1 + prn->Canvas->TextWidth(s);
y2 = y1 + prn->Canvas->TextHeight(s);
MyRect.init(x1, y1, x2, y2);
printer->Canvas->FillText(MyRect, s, false, 1,
TFillTextFlags() << TFillTextFlag::ftRightToLeft, TTextAlign::taLeading,
TTextAlign::taLeading);
printer->EndDoc();
delphi下,可以正常
var
l,t,r,b: Integer;
s: String;
source, dest : TRectF;
begin
//Set default DPI for the printer. The SelectDPI routine defaults
//to the closest available resolution as reported by the driver.
Printer.ActivePrinter.SelectDPI(1200, 1200);
Printer.BeginDoc;
//Print country name on top.
Printer.Canvas.Font.Size := 15;
Printer.Canvas.Font.Family := 'Arial';
Printer.Canvas.Font.Style := [TFontStyle.fsbold];
Printer.Canvas.Fill.Color := claBlack;
Printer.Canvas.Fill.Kind := TBrushKind.bkSolid;
s := '打印测试';
l := 10;
t := 10;
r := l + Round(Printer.Canvas.TextWidth(s));
b := t + Round(Printer.Canvas.TextHeight(s));
Printer.Canvas.FillText(TRectF.Create(l, t, r, b), s, false, 1, [TFillTextFlag.ftRightToLeft], TTextAlign.taLeading, TTextAlign.taLeading);
Printer.Canvas.Font.Size := 20;
Printer.Canvas.Font.Family := '黑体';
s := '打印测试';
l := 20;
t := 70;
r := l + Round(Printer.Canvas.TextWidth(s));
b := t + Round(Printer.Canvas.TextHeight(s));
Printer.Canvas.FillText(TRectF.Create(l, t, r, b), s, false, 1, [TFillTextFlag.ftRightToLeft], TTextAlign.taLeading, TTextAlign.taLeading);
Printer.Canvas.Font.Size := 30;
Printer.Canvas.Font.Family := '宋体';
s := '打印测试';
l := 30;
t := 130;
r := l + Round(Printer.Canvas.TextWidth(s));
b := t + Round(Printer.Canvas.TextHeight(s));
Printer.Canvas.FillText(TRectF.Create(l, t, r, b), s, false, 1, [TFillTextFlag.ftRightToLeft], TTextAlign.taLeading, TTextAlign.taLeading);
Printer.EndDoc;
求c++ builder的解决方法
[解决办法]
TPrinter *printer = Printer();
[解决办法]
TPrinter *printer = new TPrinter();