- Code: Select all Expand view
- In RPreview()
[...]
local aImpre := ListadeImpresoras(), oCbx, cCbx:= GetProfString( "windows", "device" , "" ), cImpre := cCbx // mcn
[...]
// Let user change printer
@ 7, 540 SAY oSay2 PROMPT "Printer:" ;
SIZE 180, 15 PIXEL OF oBar FONT oFont
@ 3, 610 COMBOBOX oCbx VAR cCbx ;
PROMPTS aImpre ;
OF oBar FONT oFont PIXEL SIZE 150,350 ;
ON CHANGE F_CamImpre(oDevice,cCbx)
New functions.
Thank you to Mcn
- Code: Select all Expand view
- //------------------------------------------------------------------------
// Change printer
// By Mcn
//
//
//------------------------------------------------------------------------
FUNCTION f_CamImpre (oDevice, cCbx )
local cPrinter
// Default printer
cPrinter := GetProfString( "windows", "device" , "" )
// Change printer selected
WriteProfString( "windows", "device", cCbx )
SysRefresh()
PrinterInit()
// Trick
DeleteDC( oDevice:hDC ) // Sugestion by Enrico M. Giordano
// Load
oDevice:hDC := GetPrintDefault( GetActiveWindow() )
SysRefresh()
// Restore original printer
WriteProfString( "windows", "device", cPrinter )
RETURN nil
//------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Printer´s List
// By Mcn
//
// ------------------------------------------------------------------------
FUNCTION ListadeImpresoras()
local cEntries := StrTran( GetProfString( "Devices" ), Chr( 0 ), CRLF )
local n
local ctext
local aPrinters := {}
for n = 1 to MlCount( cEntries )
cText := AllTrim( MemoLine( cEntries,, n ) )+","+GetProfString( "Devices", MemoLine( cEntries,, n ) )
aadd(aprinters, cText )
next
return aPrinters
// ------------------------------------------------------------------------