home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / WIN-OS2.SWG / 0002_Printing in TPW.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  2.1 KB  |  60 lines

  1. {
  2. Recently I put up a message asking for help so that I could
  3. change the font of the display, Editor, in the application unit
  4. stddlgs.pas (povided with tpw). Now that I have succeeded in doing that,
  5. I want to print out what is displayed on the screen. The printdlg
  6. function appears to be what I should use, according to on-line help. I
  7. have added the method below to my own TDataWindow object (inheriting
  8. the TFileWindow object from stddlgs.pas). It calls PrintDlg successfully
  9. (the result of CommExtendedDlg=0) but nothing is printed. I believe that
  10. either
  11. a) I am failing to initialise PrintDialog incorrectly;
  12. b) calling PrintDlg incorrectly or
  13. c) calling StartDoc and EndDoc incorrectly.
  14.  
  15. If anyone can put be in the right direction, I would be extremely
  16. grateful.
  17.  
  18. Fiona Stephen
  19. }
  20.  
  21. procedure TDataWindow.FilePrint(var Msg: TMessage);
  22. var
  23.     reply:boolean;
  24.     output,output2:integer;
  25.     PrintDialog:TPrintdlg;
  26.     returnvalue:LongInt;
  27.     errorstr:Pchar;
  28. begin
  29.     fillchar(printdialog,sizeof(printdialog),#0);
  30.     printdialog.hdc:=editor^.hwindow;
  31.     printdialog.lstructsize:=sizeof(printdialog);
  32.     printdialog.flags:=printdialog.flags+pd_returndc;
  33.     reply:=printdlg(printdialog);
  34.     returnvalue:=CommDlgExtendedError;
  35.     errorstr:='Not identified';
  36.     CASE RETURNVALUE OF
  37.        CDERR_FINDRESFAILURE    :ERRORSTR:='CDERR_FINDRESFAILURE';
  38. (*     I've deleted the rest of the CASE statement for brevity.
  39.        Basically it tells me the result of commdlgextendederror to
  40.        check the application of printdlg.*)
  41.  
  42.     END;
  43.     if returnvalue<>0 then
  44.             output:=MessageBox(HWindow, Errorstr, 'Print Data',mb_OK)
  45.     else begin
  46.             output:=startdoc;
  47.             if output=SP_ERROR then
  48.                   output2:=MessageBox(HWindow, 'Job not started', 'Print
  49.                   Data',mb_OK)
  50.             else
  51.                   output2:=MessageBox(HWindow, 'Job started', 'Print
  52.                   Data',mb_OK);
  53.             output:=enddoc;
  54.             if output<0 then
  55.                   output2:=MessageBox(HWindow, errorstr, 'Job Not
  56.                   Finished',mb_OK);
  57.      end;
  58. end;
  59.  
  60.