小弟想写个打印预览的程序。我使用画布映射模式中的MM_ANISOTROPIC把打印机的模式大小映射到PaintBox1,这样能和打印机的画布大小相同。
在运行期调整Paintbox1的长和宽,应该相应的调整画布上的内容。
画长方形没有问题自动调整比例。可是画出文字时没有相应的调整。怎么才能让文字也相应的调整??下面是我的代码
需要一个Paintbox1控件。其它不需要。procedure TForm1.FormPaint(Sender: TObject);
Var
  PrevMapMode: Integer;
begin
  with PaintBox1 do
  Begin
    PrevMapMode := SetMapMode(Canvas.Handle, MM_ANISOTROPIC);
    SetWindowExtEx(Canvas.Handle, Printer.PageWidth, Printer.PageHeight, nil);
    SetViewportExtEx(Canvas.Handle, ClientWidth, ClientHeight, nil);
    // Darw
    Canvas.Rectangle(100,100,500,700);
    Canvas.TextOut(120,120,'test word');    SetMapMode(Canvas.Handle,PrevMapMode);
  end;
end;