I wonder if there is a simple way to switch print orientation
(poLandscape, poPotrait) inside a Printer.BeginDoc-Printer.EndDoc
environment, such that I can give each page its individual orientation
as needed.
Or even better: A simple way of printing text horizontally as well as
vertically on the same page.
Thanks for any suggestion
Jens
Woody
--
--------------------------------------------------------------
"AlGoreithm (al-gor-ith-m): A mathematical calculation performed
repeatedly
until a prior desired result is produced."
----------------------------------------------------------------
"Jens Reinhardt" <jrein...@foni.net> wrote in message
news:3A3A4DA9...@foni.net...
procedure TForm1.Button2Click(Sender: TObject);
var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hDeviceMode: THandle;
pDevMode: PDeviceMode;
begin
With Printer Do Begin
BeginDoc;
try
Canvas.font.size := 20;
Canvas.font.name := 'Arial';
Canvas.TextOut( 50, 50, 'This is portait');
GetPrinter(Device, Driver, Port, hDeviceMode);
pDevMode := GlobalLock( hDevicemode );
With pDevMode^ Do Begin
dmFields := dmFields or DM_ORIENTATION;
dmOrientation := DMORIENT_LANDSCAPE;
End;
{ Cannot use NewPage here since the ResetDc will
only work between EndPage and StartPage. As a consequence
the Printer.PageCount is not updated. }
Windows.EndPage( Printer.Handle );
If ResetDC( canvas.Handle, pDevMode^ ) = 0 Then
ShowMessage( 'ResetDC failed, '+SysErrorMessage(GetLastError));
GlobalUnlock( hDeviceMode );
Windows.StartPage( Printer.Handle );
Printer.Canvas.Refresh;
Canvas.font.size := 20;
Canvas.font.name := 'Arial';
Canvas.TextOut( 50, 50, 'This is landscape');
finally
EndDoc;
end;
End;
end;
>
> Or even better: A simple way of printing text horizontally as well as
> vertically on the same page.
You can rotate fonts (true-type fonts only) using API functions.
procedure TForm1.Button3Click(Sender: TObject);
var
lf: TLogfont;
begin
with printer do begin
begindoc;
canvas.font.Name := 'Arial';
canvas.font.Size := 24;
canvas.textout( 100, 100, 'Das ist normaler Text' );
GetObject( canvas.font.handle, Sizeof(lf), @lf);
lf.lfescapement := 450;
lf.lforientation := 450;
Canvas.Font.handle := CreateFontIndirect( lf );
canvas.TextOut( 100, 1500, 'Das ist gedrehter Text');
Canvas.Font.Handle := 0;
EndDoc;
end;
end;
Text placement can be bit tricky with rotated fonts.
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: Till Feb.2001 i will only visit the groups on weekends, so be
patient if i don't reply immediately.