Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Printer DevMode Problem
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01321434
Message ID:
01323537
Views:
33
Hi Sergey

Here is my modified test code for printing the RTF files. The printer settings are being set because I check them by looking at the VFP page setup dialog. However the ActiveX control ignores them. The ActiveX is supposed to use Windows print settings. So I assumed that when VFP sets the printer environment it is setting the Windows printer environment but perhaps not. When I open the page setup dialog using the ActiveX control it does not contain the same information as that of VFP.

Regards,
Simon White
*
* Test printing RTF files
*
LParameters tcFile
  Local lo
  lo=CreateObject("conGPEditor")
  lo.Open(tcFile)
   =SetPrinterDevMode(goApp.oPrintParam)
  
*
* Print the document using the ActiveX control
* but it ignores the printer settings!!!!
*  
  lo.Print(goApp.oPrintParam.Printer)
  
*
* Now I open a document and print it from VFP9
* and it prints as expected.  If I check the
* page setup dialog it contains the proper settings
*  
  
  Modify Command test4

Return   
Procedure SetPrinterDevMode
   Lparameters toParam
   Local lcRpt,ln1,ln2,ln3,ln4,ln5,ln6
   lcRpt=Sys(2015)
   =PushWorkArea()
   Select 0
   Create Cursor Temp (Test C(10))
   Select 0
   Create Report (gcTmp+lcRpt+".frx") From Temp
   Use In Select("Temp")
   Use (gcTmp+lcRpt+".frx") Exclu Alias UPDevMod
   Set Printer to (toParam.Printer)
   Sys(1037,2)
   ln1=At("ORIENTATION",UPDevMod.Expr)
   ln2=At("PAPERSIZE",UPDevMod.Expr)
   Replace Next 1 UPDevMod.Expr With Stuff(UPDevMod.Expr,ln1,ln2-ln1,"ORIENTATION=1"+Chr(13)+Chr(10))
   ln2=At("PAPERSIZE",UPDevMod.Expr)
   ln3=At("ASCII",UPDevMod.Expr)
   Replace Next 1 UPDevMod.Expr With Stuff(UPDevMod.Expr,ln2,ln3-ln2,"PAPERSIZE="+Transform(GetPaperSize(toParam.PaperSize))+Chr(13)+Chr(10))
   ln4=At("COPIES",UPDevMod.Expr)
   ln5=At("DEFAULTSOURCE",UPDevMod.Expr)
   Replace Next 1 UPDevMod.Expr With Stuff(UPDevMod.Expr,ln4,ln5-ln4,"COPIES=2"+Chr(13)+Chr(10))
   If toParam.Tray<>"-1"
      ln5=At("DEFAULTSOURCE",UPDevMod.Expr)
      ln6=At("PRINTQUALITY",UPDevMod.Expr)
      Replace Next 1 UPDevMod.Expr With Stuff(UPDevMod.Expr,ln5,ln6-ln5,"DEFAULTSOURCE="+toParam.Tray+Chr(13)+Chr(10))
   EndIf
   Sys(1037,3)
   Use In Select("UPDevMod")
   =PopWorkArea()

EndProc
>Can you post RTF printig code?
>
>>Yes it returns 1.
>>
>>Simon
>>
>>
>>>Did you check what Sys(1037,3) returns?
>>>
>>>>
>>>>I am using an ActiveX control to print RTF files. Since this will be used in an automated environment I need to be able to configure the printer settings without user intervention. So after reading articles about the WinAPI and articles by other VFP programmers such as Barbara Peisch I began testing the following code. The print parameters are contained in object (oPrintParam) which is attached to my main application object (goApp). So I wrote a program to convert the parameters into a Printer DevMode Structure which I then write to the printer using Sys(1037).
>>>
>>><snip>
Simon White
dCipher Computing
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform