Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide to Clip-4-Win version 3.0 - <b>printdlg()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
PrintDlg()
Set up printer and print job information
------------------------------------------------------------------------------

Syntax
PrintDlg( <aInfo> )   -->   lSuccess   (or NIL if user cancelled)

Arguments
<aInfo> is an array that PrintDlg() will fill with information
about the printer and print job.  This array should be of length
PD_LENGTH (a manifest constant found in the COMMDLG.CH header file).

Returns
A logical value or NIL: True (.T.) if successful, or False
(.F.) if not.
If the user presses ESC to exit the dialog box, the function
will return a NIL.

Description
This function is similar to (but more useful than) the
GetPrintDC() function.  Like GetPrintDC(), it displays the
Windows printer common dialog so that the user can easily
configure the settings.  However, instead of simply returning
a handle for drawing on the printer, it returns the following
information in the elements of <aInfo>:

Note: for compatibility, you can define upper-case versions of
these names (see the COMMDLG.CH file).

Manifest Constant
in COMMDLG.CH       Description

PD_hwndOwner        Window to own the dialog box (usually the
                    current window, which can be determined by
                    calling the SelectWindow() function)
PD_hDC              The device context to use for printing
PD_nFlags           (See below for more information)
PD_nFromPage        Page # to print from (if applicable)
PD_nToPage          Page # to print to (if applicable)
PD_nMinPage         Minimum page # to print (if applicable)
PD_nMaxPage         Maximum page # to print (if applicable)
PD_nCopies          Number of copies desired
PD_Length           Length of target array

The following are possible values for the PD_nFlags entry:

Manifest Constant
in COMMDLG.CH            Value

PD_ALLPAGES              0
PD_SELECTION             1
PD_PAGENUMS              2
PD_NOSELECTION           4
PD_NOPAGENUMS            8
PD_COLLATE               16
PD_PRINTTOFILE           32
PD_PRINTSETUP            64
PD_NOWARNING             128
PD_RETURNDC              256
PD_RETURNIC              512
PD_RETURNDEFAULT         1024
PD_SHOWHELP              2048
PD_USEDEVMODECOPIES      262144
PD_DISABLEPRINTTOFILE    524288
PD_HIDEPRINTTOFILE       1048576

You may use one or more of these items to initialize the
PD_nFlags element in <aInfo>.  The default value is
PD_RETURNDC.  For example, if you do not want to give the user
the option to print to a file, you could also use the
PD_DISABLEPRINTTOFILE or PD_HIDEPRINTTOFILE values.

If a handle to a device context is returned be sure to free it
eventually, using the DeleteDC() function.

NOTE: If the user chooses "print to file", Windows will
automatically prompt for a filename and handle the redirection
accordingly.  The file thus created will be of Metafile
format.

There are other settings in COMMDLG.CH which are not yet
supported, and are thus not listed herein.  These are either
indicated as "TBD" or commented out entirely.  When these
items become supported, this documentation will be revised
accordingly.

Example
#include "commdlg.ch"

local  aPrintDlg := array( PD_Length )
local  i, x

// set up initial values for the printer dialog
aPrintDlg[ PD_hwndOwner ] := SelectWindow()
aPrintDlg[ PD_nFlags ]    := PD_RETURNDC   // this is also the default

x := PrintDlg( aPrintDlg )

if  x == NIL  .or.  ! x
   // cancelled by the user
   return nil
endif
StartDoc( aPrintDlg[ PD_hDC ], "Test Output" )
for i := 1 to aPrintDlg[ PD_nCopies ]
   StartPage( aPrintDlg[ PD_hDC ] )
   TextOut( aPrintDlg[ PD_hDC ], 100, 50, "Clip-4-Win Printer Test Page" )
   Rectangle( aPrintDlg[ PD_hDC ], 0, 0, nWidth, nHeight )
   MoveTo( aPrintDlg[ PD_hDC ], nWidth, 0 )
   LineTo( aPrintDlg[ PD_hDC ], 0, nHeight )
   EndPage( aPrintDlg[ PD_hDC ] )
next i
EndDoc( aPrintDlg[ PD_hDC ] )
DeleteDC( aPrintDlg[ PD_hDC ] )
return nil


See Also: DeleteDC() GetPrintDC()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson