Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Printer - current one
Message
De
27/02/1998 18:05:12
Christopher Holtz
Integral Computer Services, Inc.
Rochester, New York, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00081362
Message ID:
00081808
Vues:
32
Also note, that in NT, the default printer is
not stored as a value, but as a key. In this
case you would need a tool that is able to
return registry keys names (mine only works
with values.. grrr).

- Chris Holtz
>>>Look at the Common Dialogs ActiveX control. It will allow you to retrieve this information.
>>>
>>
>>George,
>>
>>Thanks. I have looked at this control, this allows me to essentially do a SYS(1037), however, I cannot see how I can retrieve the name of the selected printer.
>>
>>Perhaps you could elaborate further.
>>
>>Regards,
>>
>>Kev
>
>Kev,
>
>Since I abstracted the process, I'd forgotten that you can't do this directly with the Common Dialogs control. I use the following workaround. First, I retrieve the name of the current default printer from WIN.INI. Second, I set the .PrinterDefault property of the control to .T. This will cause the user's selection to be reflected in WIN.INI. Third, after the user selects the printer, I retrieve it from WIN.INI, then I write the original default back. In code, it might look something like:
>
>
>* Using Foxtools to get and write the printer
>lcbuffer = SPACE(200)
>lnbuflen = LEN(lcbuffer)
>lcdefault = ""
>* Get current default
>lnbuflen = GetProStrg('windows', 'device', lcdefault,;
>  @lcbuffer, lnbuflen)
>lcorgprnt = LEFT(lcbuffer, lnbuflen)
>* Assuming the control has been created with CREATOBJECT()
>oPrinter.PrinterDefault = .T.
>oPrinter.ShowPrinter
>* Get the new printer
>lcbuffer = SPACE(200)
>lnbuflen = LEN(lcbuffer)
>lcdefault = ""
>lnbuflen = GetProStrg('windows', 'device', lcdefault,;
>  @lcbuffer, lnbuflen)
>lcnewprnt = LEFT(lcbuffer, lnbuflen)
>* Restore the original
>= PutProStrg('windows', 'device', lcorgprnt)
>lcprntname = LEFT(lcnewprnt, AT(',' lcnewprnt) - 1)
>
>
>You'd probably want to create a function to do the retrieves from the INI file rather than the redundancy shown above. The only drawback to the above that I'm aware of is that it won't work in Win NT. You'd have to read and write to the registry.
>
>hth,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform