Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Choosing a printer
Message
From
06/08/1999 15:04:28
 
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00250441
Message ID:
00250846
Views:
32
>Well, I tried it. It didn't seem to do anything. The report still comes out of the default printer. Here's my code:
>
>lcPrinter = GETPRINTER()
>DO setprntr WITH lcPrinter
>.
>.
>.
>LOOP
>Stuff to create cursor
>.
>.
>.
>REPORT FORM (gc_adrvprg+"cpcklst") NOCONSOLE TO PRINTER
>ENDLOOP
>
>Can you see what I'm doing wrong?
>
>Thanks,
>
>Michelle
>
>


Michelle,

You still need to clear out the EXPR, TAG, and TAG2 fields from the first record of the report .FRX file. If you do that, it'll work.



>
>>>I saw the SET PRINTER, but it seemed like a DOS holdover. I'll give it a shot.
>>>
>>
>>
>>The command is SET PRINTER TO NAME nameofprinter
>>
>>nameofprinter can be got from getprinter()
>>
>>This works SOMETIMES but not always. On NT machines especially this works very erratically if at all.
>>
>>What I do is get the name of the printer and call a function I have made called SETPRINTER(). This uses API's to write to the WIN.INI - Yes VFP does read from the win.ini where printer info is needed.
>>
>>So I just read the entry for the selected printer from the WIN.INI and write it out to the WIN.INI as the Current Default printer. Then another API to broadcast this change to all open apps.
>>
>>Code follows:
>>FUNCTION setprntr
>>PARAMETERS p_name
>>* p_name is the name of the printer
>>* This is set as the default
>>IF EMPTY(p_name)
>> RETURN
>>ENDIF
>>
>>SET LIBRARY TO FOXTOOLS.fll ADDITIVE
>>*aa=RegFn("GetWinIni","CCC@CI","I")
>>aa=RegFn("GetProfileString","CCC@CI","I")
>>ss=RegFn("SendMessage","IIIC","I")
>>*ww=RegFn("WriteWinIni","CCC","I")
>>ww=RegFn("WriteProfileString","CCC","I")
>>fbuffer=SPACE(255)
>>fsize=255
>>fcat="PrinterPorts"
>>fother=""
>>bb=CallFn(aa,fcat,p_name,fother,@fbuffer,fsize)
>>*bb=GetWinIni("PrinterPorts",p_name,"",@buffer,255)
>>IF bb=0
>> Wait window "Could not set the Default Printer to "+ALLTRIM(p_name)
>> RELEASE LIBRARY FOXTOOLS.fll
>> Return .F.
>>ENDIF
>>* got the driver and port string now parse it
>>p_driver = substr(fbuffer,1,AT(",",fbuffer)-1)
>>p_port = substr(fbuffer,AT(",",fbuffer)+1,AT(",",fbuffer,2)-AT(",",fbuffer)-1)
>>p_line = p_name+","+p_driver+","+p_port
>>* write it out
>>bb=CallFn(ww,"windows","Device",p_line)
>>*bb=WriteWinIni("windows","Device",p_line)
>>IF bb=0
>> Wait window "Could not set the Default Printer to "+ALLTRIM(p_name)
>> RELEASE LIBRARY fxtool16.fll
>> Return .F.
>>ENDIF
>>* broadcast it
>>bb=CallFn(ss,65535,26,0,"windows")
>>*bb= SendMessage(65535,26,0,"windows")
>>
>>IF bb=0
>> Wait window "Could not set the Default Printer to "+ALLTRIM(p_name)
>> RELEASE LIBRARY FOXTOOLS.fll
>> Return .F.
>>ELSE
>>* wait window "Default Printer set to "+ALLTRIM(p_name)
>>ENDIF
>>
>>RELEASE LIBRARY FOXTOOLS.fll
>>RETURN
>>* eof setprntr
>>
>>
>>The commented out calls are for 16 bit fox
>>
>>Works every time
>>
>>Hope this helps
>>
>>Bernard
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform