Board index » cppbuilder » how to get the currently selected printer name from a PrintDialog?

how to get the currently selected printer name from a PrintDialog?


2003-12-11 04:53:44 AM
cppbuilder5
when using PrintDialog to select a printer, how to get the name of the
printer ?
 
 

Re:how to get the currently selected printer name from a PrintDialog?

"Richard Yu" < XXXX@XXXXX.COM >wrote:
Quote
when using PrintDialog to select a printer, how to get the
name of the printer ?
The TPrintDialog does not have a option for selecting a
printer. That's why I use my own dialog.
To display a list of printers for the user to select from:
// populate the combo box
prnComboBox->Items->Assign( Printer()->Printers );
// make the currently selected printer the selected item in the Combo box
prnComboBox->ItemIndex = Printer()->PrinterIndex;
To set the printer to the default printer:
Printer()->PrinterIndex = -1;
HTH
~ JD
 

Re:how to get the currently selected printer name from a PrintDialog?

"JD" < XXXX@XXXXX.COM >wrote in message
Quote
The TPrintDialog does not have a option for selecting a
printer.
Yes, it does. All TPrintDialog does is calls the PrintDlg() function to
display the OS's standard printing dialog, which does have that option.
There is a drop-down menu on that dialog for selecting from the currently
installed printers.
Gambit
 

{smallsort}

Re:how to get the currently selected printer name from a PrintDialog?

"Richard Yu" < XXXX@XXXXX.COM >wrote in message
Quote
when using PrintDialog to select a printer, how to get the name
of the printer ?
Print Execute() returns, the global TPrinter object (accessed via the
Printer() function) is updated to reflect the printer settings that were
choosen in the dialog. So, to get the name, simply use the
TPrinter::Printers and TPrinter::PrinterIndex properties.
Gambit
 

Re:how to get the currently selected printer name from a PrintDialog?

My code like this:
if( PrintDialog1->Execute() )
{
int index=Printer()->PrinterIndex;
MyPostScriptPrinting(printerName);
}
when starting the PrintDialog1, it allow you to set curr printer, the index
chanded each time I make a sel, but I need the printer name in my
application.
"JD" < XXXX@XXXXX.COM >wrote in message
Quote

"Richard Yu" < XXXX@XXXXX.COM >wrote:
>when using PrintDialog to select a printer, how to get the
>name of the printer ?

The TPrintDialog does not have a option for selecting a
printer. That's why I use my own dialog.

To display a list of printers for the user to select from:

// populate the combo box
prnComboBox->Items->Assign( Printer()->Printers );
// make the currently selected printer the selected item in the Combo
box
prnComboBox->ItemIndex = Printer()->PrinterIndex;

To set the printer to the default printer:

Printer()->PrinterIndex = -1;

HTH

~ JD

 

Re:how to get the currently selected printer name from a PrintDialog?

ok now ,
I can use Printer()->GetPrinter(PrnName, PrnDrive, PrnPort, Dmod);
"Richard Yu" < XXXX@XXXXX.COM >wrote in message
Quote
My code like this:

if( PrintDialog1->Execute() )
{
int index=Printer()->PrinterIndex;
MyPostScriptPrinting(printerName);

}

when starting the PrintDialog1, it allow you to set curr printer, the
index
chanded each time I make a sel, but I need the printer name in my
application.

"JD" < XXXX@XXXXX.COM >wrote in message
news:3fd795fb$ XXXX@XXXXX.COM ...
>
>"Richard Yu" < XXXX@XXXXX.COM >wrote:
>>when using PrintDialog to select a printer, how to get the
>>name of the printer ?
>
>The TPrintDialog does not have a option for selecting a
>printer. That's why I use my own dialog.
>
>To display a list of printers for the user to select from:
>
>// populate the combo box
>prnComboBox->Items->Assign( Printer()->Printers );
>// make the currently selected printer the selected item in the
Combo
box
>prnComboBox->ItemIndex = Printer()->PrinterIndex;
>
>To set the printer to the default printer:
>
>Printer()->PrinterIndex = -1;
>
>HTH
>
>~ JD
>