[DUG] Setting tabs on a printer

Jolyon Smith jsmith at deltics.co.nz
Tue Dec 8 14:43:58 NZDT 2009


Settingt tab stops in this way is something only an EDIT class control can
understand (the EM_ in the message constant name indicates: EDIT [control]
MESSAGE).

 

The Handle of the printer is not even a Window Handle, it's a Device Context
Handle.

 

To output text that respects tab stops to an arbitrary device context, I'd
investigate TabbedTextOut():

 

http://msdn.microsoft.com/en-us/library/dd145129(VS.85).aspx

 

 

From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz] On
Behalf Of Marshland Engineering
Sent: Tuesday, 8 December 2009 2:01 p.m.
To: delphi at delphi.org.nz
Subject: [DUG] Setting tabs on a printer

 

I can't send a tab setting to the printer 

The routine works with a memo but fPrn.Handle gives and error.

Something to do with fPrn and system.text   

 

 

 

procedure TfMain.puExpListClick(Sender: TObject);
var
   fPrn: system.text;
   TabArray : array[0..4] of integer;
begin
   TabArray[0] := 350;// div DialogUnitsX;  //Tab Positions
   TabArray[1] := 380; //div DialogUnitsX;
      begin
         with Printer.Canvas do begin
            PrinterSetupDialog1.execute;
            Font.Name := 'Courier New';
            Font.size := 14;
            AssignPrn(fPrn);
            Rewrite(fPrn);
            SendMessage(fPrn,EM_SETTABSTOPS,2,LongInt(@TabArray)) ; // This
line does not work

            SendMessage(fPrn.Handle,EM_SETTABSTOPS,2,LongInt(@TabArray)) ;
//This gives an error.

            // SendMessage(memo.Handle,EM_SETTABSTOPS,2,LongInt(@TabArray))
; //This works on the memo.

        end;
      end
   dm.tblExpJob.First;
         begin  // Heading
            with Printer.Canvas do begin
               Font.size := 12;
               WriteLn(fPrn,#10+#10);
               WriteLn(fPrn,'     '+dm.tblData['Desc']+#13+#10);
               Font.Size := 10;
            end;
         end

 

etc

 

            WriteLn(fPrn,'  '+dm.tblExpJob.FieldByName('Date').AsString
            +'  '+dm.tblExpJob.FieldByName('Desc').AsString
            +'  '+#9+dm.tblExpJob.FieldByName('Person').AsString)  // Trying
to format the Person on TAB
         CloseFile(fPrn);

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20091208/8ebd72ec/attachment.html 


More information about the Delphi mailing list