fPRINTERDIALOG


Quick Data

Header file:printer.h
Object name:fPRINTERDIALOG
Object index:1 of 2 Objects (the other is fPRINTER)

General Description

The fPRINTERDIALOG is a class to show a common dialog that prompts the user to select a printer to print to. From this dialog the user can select the number of copies, change printer settings, and do most other things that you can do with printer dialogs.

If you do not wish this class to be included with the fPRINTER component, then just #define F_PRINTER_H_NO_DIALOG before you include the file. However, if you disable this dialog class, you will not be able to call the StartPrintJobDialog() function from within fPRINTER - so please keep this in mind.


Methods


Prototype Description

bool Execute(HWND Handle); This function starts the dialog and waits for the user to accept what the dialog says, and allows the user to change things. If the user clicks Ok, then this function will return TRUE, otherwise this function returns FALSE.
void SetFromPage(int Number);
void SetToPage(int Number);
void SetMinPage(int Number);
void SetMaxPage(int Number);
These functions are all related in intricate ways. The first two functions set what numbers are in the dialog's 'To' and 'From' page boxes - ie. what pages to print, say from page 1 to 10 or 2 to 3. The last two functions set what the maximum and minimum limit for these are - and the dialog will not allow the user to go past these values.
void SetCopied(int N); This function sets the default number of copies to show in the dialog.
void SetSelectAllPagesRadio(bool Set); This function sets whether or not to have the 'All' radio button is selected by default. The 'All' radio button will indicate that the user wishes to print all of the pages. Passing TRUE will make this selected, whilst passing FALSE will make it not be selected.
void SetSelectSelectionRadio(bool Set); This function sets whether or not the 'Selection' radio button is selected by default. The 'Selection' radio button indicates that the user wishes to print only the selection from whatever document that they were looking at. Passing TRUE will select that radio button, whilst passing FALSE will make it not-select that radio button.
void SetNoPageSelectionBoxes(bool Set); This function sets whether or not the user can select the pages that they wish to print from inside the dialog. Passing TRUE will disable the selection, whilst passing FALSE will enable the selection again.
void SetNoSelectionRadio(bool Set); This function sets whether or not the dialog should allow the user to use the 'Selection' Radio button. Passing TRUE will disable this option, whilst passing FALSE will enable it.
void SetNoPrintToFile(bool Set); This function sets whether or not the user is able to specify that they wish to print to file. Passing TRUE will disable the user from selecting print to file, whilst passing FALSE will allow this to happen.
void SetHidePrintToFile(bool Set); Just disabling the 'Print to File' option is not enough? Then hide it. Passing TRUE will hide the setting, or passing FALSE will allow it to be shown.
void SetCheckPrintToFile(bool Set); This function will set whether or not the print to file checkbox is selected by default. Passing TRUE will make the checkbox be selected, or passing FALSE will make it unselected.
void SetCollateChecked(bool Set); This function sets whether or not the collate checkbox is checked or not. Passing TRUE will make it checked, or passing FALSE will make it unchecked.
void SetHardwareOnlyCopiesAndCollate(bool Set); This function makes the dialog show the 'number of copies' and 'collation' choices if the selected printer can handle that via it's hardware. Passing TRUE will make it only show if the hardware can do that, or passing FALSE will show those settings regardless.
void SetSuppressNoPrinterWarning(bool Set); This function sets whether or not the dialog should warn the user that no printers are installed if that is the case. If that is the case, the user will be warned, and the dialog will return FALSE. Pass TRUE to make the dialog not show this warning, or FALSE to allow the dialog to issue this warning if relevant.
void SetGetDeviceContext(bool Set); You'll probably only use this option if you are manually creating a print job. This setting makes the printer dialog get the printer's device context before it returns - which can be quite useful indeed. You can retrieve the device context with later functions. Passing TRUE makes the dialog return a device context, or passing FALSE makes it not return a device context. Please note that if the dialog is called from withing the fPRINTER object, then this setting is on by default. Please keep it that way.
int GetFromPage(void);
int GetToPage(void);
This function returns the pages that the user wishes to print. In this case, the user might have said that they want the pages from 2 to 5 - in which case, GetFromPage() returns 2, and GetToPage() returns 5.
int GetMinPage(void);
int GetMaxPage(void);
These function return the limits to the number of pages that the user can select to print from. These functions are just here so that you can return the page count if you happen to forget what values you originally put in...
int GetCopies(void); This function returns the number of copies that the user wants printed.
bool GetSelectAllPagesRadio(void); This function returns whether or not the 'All pages' radio was selected on the dialog.
bool GetSelectSelectionRadio(void); This function returns whether or not the 'Selection' radio was selected on the dialog.
void GetCheckPrintToFile(void); This function returns whether or not the 'Print to File' thingy was checked.
bool GetCollateChecked(void); This function returns whether or not the 'Collate' checkbox was checked.
HDC ReturnDeviceContext(void); If you wanted the dialog to return a device context, you can retrieve it through this function. Handy.

Sample Code

The following snippet gives a basic idea of how to use this component.


//Create an instance...
fPRINTERDIALOG PrinterDialog;

//Set up the pages...
PrinterDialog.SetMinPage(1);
PrinterDialog.SetMaxPage(10);
//The above lines mean that the user can not print the pages
//outside of the range 1-10.

//Now just show the dialog...
if (PrinterDialog.Execute(Window.GetHandle()))
   {
   //User clicked OK! Print job is to go ahead!
   } else {
   //User did not click OK. Don't print!
   }

//And you can automatically call one of these dialogs
//from the fPRINTER class - just see the
//documentation on that for information about that.
//fPRINTER provides a complete interface for printing;
//so I'd recommend checking that out.

Back to indexThe FreeFoote Foundation Classes Documentation