Category : Pascal Source Code
Archive   : TPWPRINT.ZIP
Filename : TESTPRN2.PAS

 
Output of file : TESTPRN2.PAS contained in archive : TPWPRINT.ZIP
PROGRAM TestPrn;
{$F+}
{-- Sample program using the printer unit --}

Uses wObjects,winProcs,repPrn,stdDlgs,WinTypes,Strings;
const
cmSetPrint = 1;
cmPrintFile = 2;

TYPE
tTestApp = object(tApplication)
procedure InitMainWindow; virtual;
end;

pPrnWindow = ^tPrnWindow;
tPrnWindow = object(tWindow)
aPrinter: pReportPrinter;
constructor Init(aParent: pWindowsObject;aTitle: pChar);
procedure setPrinter(var msg:tMessage);virtual cm_first + cmSetPrint;
procedure filePrint(var msg: tMessage);virtual cm_first + cmPrintFile;
end;
pathStr = array[0..64] of Char;


{$R test.res}

procedure tPrnWindow.setPrinter(var msg:tMessage);
begin
aPrinter := new(preportPrinter,Init(hInstance,@self,10));
aPrinter^.prnDeviceMode(hWindow);
dispose(aPrinter,Done);
End;

Function fileIsOpen(var t: Text;f: pathStr): Boolean;
var
ioCode: integer;
Begin
{$I-}
assign(t,f);
reset(t);
ioCode := ioResult;
fileIsOpen := (ioCode = 0);
{$I+}
end;

procedure tPrnWindow.filePrint(var msg: tMessage);
{-- Gets a file name from the user, and prints it out. (the file, not
the file name --}
var
fName: pathStr;
textFile: Text;
tLine: array[0..79] of char;

Begin
fName[0] := ' ';
if (Application^.ExecDialog(new(pInputDialog,Init(@self,'File to Print',
'Enter File Name: ',@fName,SizeOf(fName)))) = id_OK) then begin
if (FileIsOpen(textFile,fName)) then begin

aPrinter := new(pReportPrinter,Init(hInstance,@self,60)); {init the printer object}
aPrinter^.setDefaults('Heading');
if aPrinter^.Start('PrnTest',hWindow) then begin {start the printer}
while not eof(textFile) do begin
readln(textFile,tLine);
aPrinter^.outText(@tLine); {send each line to the printer object}
End;
close(textFile);
aPrinter^.Finish; {finish the print job}
dispose(aPrinter,Done);
End;
End;
End;
end;

constructor tPrnWindow.Init(aParent: pWindowsObject;aTitle: pChar);
begin
tWindow.Init(aParent,aTitle);
Attr.Style := WS_OverlappedWindow or ws_Vscroll or WS_Hscroll;
attr.Menu := loadMenu(hInstance,pChar(100));
end;

Procedure tTestApp.InitMainWindow;
Begin
MainWindow := new(pPrnWindow,init(nil,'Printer Test'));
End;


var
tApp: tTestApp;

Begin
tApp.Init('Printer Test');
tApp.Run;
tApp.Done;
End.

  3 Responses to “Category : Pascal Source Code
Archive   : TPWPRINT.ZIP
Filename : TESTPRN2.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/