TPW v1.5 - Printing 
Author Message
 TPW v1.5 - Printing

I know it is prob. obvious but HOW do you print in
Borland TPW v1.5. There is no referrence to it in the
manuals.

--
/----------------------------------------------------------\
| Kedgeree the Elder | These opinions are not necessarily  |

\----------------------------------------------------------/



Wed, 18 Jun 1902 08:00:00 GMT  
 TPW v1.5 - Printing


Quote:

>I know it is prob. obvious but HOW do you print in
>Borland TPW v1.5. There is no referrence to it in the
>manuals.

>--
>> You are right there is no obvious/documented way. There are several

technical books that I can recommend. Especially the Tom Swan book
"Turbo Pascal for Windows 3". I have some generic code which deals with
text only, but could be adapted to graphics if you have the
time/inclination.
Martin
Quote:
>/----------------------------------------------------------\
>| Kedgeree the Elder | These opinions are not necessarily  |

>\----------------------------------------------------------/



Wed, 18 Jun 1902 08:00:00 GMT  
 TPW v1.5 - Printing

Quote:


>>I know it is prob. obvious but HOW do you print in
>>Borland TPW v1.5. There is no referrence to it in the
>>manuals.

I find the best way is to use the Windows PrintDlg() function. Look it
up in help files. If you call it with Flags:= PD_ReturnDC, your
printers (familiar) dialog box comes up. On closing 'OK', you get a
Device context you can use as is usual in Paint routines.

I've dug up some old code which gives a crude idea. If you want more,
please email.

procedure MYwindow.Hardcopy(var Msg: TMessage);
Const Factor = 3; { factor to scale up type size }
  TD:TDocInfo = (cbSize:0; lpszDocname:nil; lpszOutput:nil); { blank
TDocInfo }

var Metrics:TTextMetric; YPix, Pageheight, TxtHgtOverall: integer;
  PD: TPrintDlg; PtrDev: Pointer;
  Err: Integer; TDc: TDocInfo;

begin { Printer Dialog }
  FillChar(PD, Sizeof(PD), #0); { fill PD with nulls}
  with PD do
  begin
    lStructSize := Sizeof(TPrintDlg); {now fill PD's essential fields}
    hWndOwner := HWindow;
    Flags:= PD_ReturnIC or PD_ReturnDefault;  { return information
context - ie, the next stmt will retrieve a device context, papersizes
etc, but you can't print on it}
    if PrintDlg(PD) then  { with PD_Return Default, dialog not shown}
      begin  { get text & paper sizes from Information Context }
       GetTextMetrics(PD.hDC, Metrics);
       TxtHgtOverall:= MulDiv(Metrics.tmHeight,110,100); { add 10% }
       YPix:= GetDeviceCaps(PD.hDC, logpixelsY);
       Pageheight:= GetDeviceCaps(PD.hDC, VertSize);
       PageHeight:= Muldiv(PageHeight, 10*Ypix, 260); { 260 = 254 + 2%

Quote:
}

      end;
     { Now, set up start and finish page numbers }
    nMinpage:= 1;
   { nMaxpage:= 1 +(Numrows + 1) DIV (3000 DIV (Muldiv( 3*ChHgt
,110,100))); }
   { Old estimate. Calculates No. of 10" pages: 300 pixels per inch
       - ie 3x pixels per inch for screen. Better to use the Info
context as above.}
    nMaxpage:= 1 +(Numrows + 1) DIV (PageHeight DIV TxtHgtOverall);
    nFromPage:= nMinPage; nToPage:= nMaxPage;
    Flags := PD_ReturnDC; {ie set up to return a DC which can be
printed on}
  end;
  if PrintDlg(PD) then
  begin
  {- ... Print using PD.hDC device context. }

    If PD.hDC <> 0 then
    begin
     Err:= StartDoc(Pd.hDC, TD);
     If Err > 0 then
       PrintDoc(PD.hDC, PD.nFromPage, PD.nToPage, TxtHgtOverall,
PageHeight, Err); {This is a routine like Paint which uses PD.hDC as a
*canvas*}
     If Err > 0 then EndDoc(PD.hDC);
    end;
    DeleteDC(PD.hDC);
    if PD.hDevMode  <> 0 then GlobalFree(PD.hDevMode);
    if PD.hDevNames <> 0 then GlobalFree(PD.hDevNames);
  end;
end;
 {Note, you have to study TDocInfo, PrintDlg, StartDoc, EndDoc etc
from TPW's online help}

Hope this gives you some pointers. Tom Swan's Borland Pascal  7.0
Programming for Windows is very good. Look at CommDlgs files.

regards

Michael Glover



Wed, 18 Jun 1902 08:00:00 GMT  
 TPW v1.5 - Printing
Thanks very much. I can now print.

--
/----------------------------------------------------------\
| Kedgeree the Elder | These opinions are not necessarily  |

\----------------------------------------------------------/



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. TPW: How to print TPW prog output ?

2. TPW: How to print TPW prog output ?

3. TPW v1.5 - Error 143

4. TPW v1.5 - How do I CHANGE the icon

5. Printing in Windows using v1.0

6. TPW 1.5 using LPT1 to print with LEXMARK PRINTER

7. Help..(TPW Printing )

8. Printing and fonts in TPW

9. TPW: How to print...

10. Problem printing color bitmap on color printer wih TPW 1.5

11. Printing with TPW 1.5

12. Printing DIB files from a TPW application

 

 
Powered by phpBB® Forum Software