Home Contents Search

Perpetual Newbie
Error Message Issue #23 skins QTime Perpetual Newbie Perpetual Newbie Perpetual Newbie Perpetual Newbie How Convert User Registration rabbit hole CASE & Classes skins Premium 5 Premium 6 Premium Domains Premium 2 Premium 3 Premium 4 Rare domains cities_realestate Similar   Websites education_sites entertainment_sites games misc_sites LLLL.com Site Acronym 2 Acronym 4 LLLLL.com LLLLL.com 2 LLLLL.com 3 Acronym 5 Acronym 6 Acronym 7 Acronym 8 Acronym 9 Acronym 10 Acronym 3 Brandable sites Pin Yin sites service_sites technology Acronym sites Payment Options About Our Office

The Perpetual Newbie - Log Entry #4 - Be Civil, Learn My Name

by Gary Mugford - mugford@aztec-net.com

I like to keep my users informed. A particular piece of information that tends to avoid trouble down the road is to have a clear label on screen as to which is the active printer. This helps avoid sending laser reports to dot matrix printers and vice-versa. And knowing where the intended destination lies allows me to change the &Print button to a &Fax button as the occasion demands it. A little thing, but it reassures the user you are in control.

Unfortunately, I used a third-party DCU to get the printer name for several years. I know, I know. You aren't supposed to use any third-party tool that you don't have source for, but it worked beautifully. Until my most recent upgrade. That's when I discovered the DCU-provider was no longer supporting or updating the tool. Oops!!!

I went through the TPrinter help section. Still couldn't come up with a solution. So, off to the internet I went, using www.deja.com to search for "Delphi printername." As has been pointed out to me, I would probably have been better off at developers.href.com (without the "www."). Despite the misguided start, I did encounter several emails, including one by Barry McClure of Grebar Systems, the providers of PrintDAT!, a very nice grid printer tool that I have been using happily. In the exchange was my solution, presented here as a function or two:

uses Printers;

{Gets FULL Printername including port designation}
function gmGetPrinterName:string;
begin
if Printer.PrinterIndex = -1
then result := 'No Default Printer Selected'
else result := Printer.Printers[Printer.PrinterIndex];
end;

{Returns the Printername without port designations}
function gmGetJustPrinterName:string;
const
s = ' on '; // include a space before and after 'on' for the pos search
begin
if Printer.PrinterIndex = -1
then result := 'No Default Printer Selected'
else begin
result := Printer.Printers[Printer.PrinterIndex];
if pos(s,result) > 0
then result := copy(result,1,pos(s,result)-1); // shaves off port
end;
end;

Gary Mugford
Idea Mechanic, Bramalea ON Canada

Copyright © 2007 undu.com                    Powered by Engineer Partner The One Stop Outsource