Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
When set printer to name selectedpriner does not work
Message
From
25/06/2003 03:36:53
Vladimir Zhuravlev
Institute of the Physics of Earth,Russia
Moscow Region, Russia
 
 
To
25/06/2003 03:20:11
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00803155
Message ID:
00803652
Views:
20
Gregory
You have asked me to report about solutions, I did find
I have one, solution and not solution
there is the site http://www.news2news.com/vfp/
about using win32 in VFP and some samples are free
I get one , called prn prompt< I include the code later, where I chnged only one string, substituted the name of the selected printer instead of taking in the code the default One
This call dialog for properties of the selected printer
After this printing on the selected printer worked form my problem client
My problem , this dialog about properties of the selected printer is senceless
But somehow it read by force something about the selected printer ( instead of sys(1037)) , and does not produce error. Unforturnatly ( for me) the sample for calling printdlg which also could help, is not open ( not free)
Vladimir

#DEFINE PRINTER_ACCESS_ADMINISTER 4
#DEFINE PRINTER_ACCESS_USE 8
DO decl

LOCAL cPrinter, hPrinter, lcPrnDefaults
*** this I changed on the name of the selected printer
** I did not call GetPrnName()
cPrinter = GetPrnName() && default printer

* PRINTER_DEFAULTS structure
lcPrnDefaults = Repli(Chr(0),8) +;
Chr(PRINTER_ACCESS_ADMINISTER) + Repli(Chr(0),3)

hPrinter = 0
IF OpenPrinter(cPrinter, @hPrinter, lcPrnDefaults) = 0
? "Error opening printer [" + cPrinter + "]"
RETURN
ENDIF

= PrinterProperties(GetActiveWindow(), hPrinter)
= ClosePrinter(hPrinter)
* end of main

FUNCTION GetPrnName
* returns default printer name from Windows Registry
LOCAL lcBuffer, lcPrinter, lcDriver, lcPort
lcBuffer = Repli(Chr(0), 120)
= GetProfileString("Windows", "Device", ",,,",;
@lcBuffer, Len(lcBuffer))
lcBuffer = STRTRAN(lcBuffer, Chr(0), "")
RETURN SUBSTR(lcBuffer, 1, AT(",", lcBuffer, 1)-1)

PROCEDURE decl
DECLARE INTEGER OpenPrinter IN winspool.drv;
STRING pPrinterName, INTEGER @phPrinter, STRING pDefault

DECLARE INTEGER GetProfileString IN kernel32;
STRING lpApp, STRING lpKey, STRING lpDefault,;
STRING @lpReturnedString, INTEGER nSize

DECLARE INTEGER ClosePrinter IN winspool.drv INTEGER hPrinter
DECLARE INTEGER GetActiveWindow IN user32

DECLARE INTEGER PrinterProperties IN winspool.drv;
INTEGER hWnd, INTEGER hPrinter
MVP-2006-2011, PHD in Math and Physics ,
host of www.foxclub.ru,
VFP lector at Interface and Microinform companies
Head science researcher of VNIIA Rosatom.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform