ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to get the name of the current Printer?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

PeterPanino

492 Posts

Posted - Apr 12 2021 :  10:47:55  Show Profile  Reply
I would like to show the Name of the current Printer (i.e. the name of the printer where the Printer dialog will print to, that could be customized in the Print dialog):

ImageEnView1.IO.DoPrintPreviewDialog(iedtDialog, '', False, 'Print (' + IECurrentPrinter.Name + ')');


But there is no IECurrentPrinter object or IECurrentPrinter.Name function.

Even the TIOPrintPreviewParams seems to not provide the name of the current Printer.

So how can I get the name of the current Printer set by the user in the Print Preview dialog?

PeterPanino

492 Posts

Posted - Apr 12 2021 :  12:00:44  Show Profile  Reply
With this code, I get the default printer in Windows:

var DefaultPrinter: array[0..79] of Char;
Winapi.Windows.GetProfileString('windows', 'device', '', DefaultPrinter, SizeOf(DefaultPrinter) - 1);
// Result: "HP Color LaserJet MFP M477fdn,winspool,Ne09:"


But as soon as the user changes the printer setting in the IE Print Preview dialog, that is not the printer where IE will print to.

So how can I get the name of the printer set by the user in the IE Print Preview dialog?
Go to Top of Page

xequte

6017 Posts

Posted - Apr 12 2021 :  19:26:14  Show Profile  Reply
Hi

To get the "active" printer you can use:


    if Printer.Printers.Count > 0 then
      Result := Printer.Printers[ Printer.PrinterIndex ];


I will make ImageEn display the active printer in the printer title bar for the next release.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

PeterPanino

492 Posts

Posted - Apr 13 2021 :  02:06:18  Show Profile  Reply
That's very nice, thank you!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: