De Default Printer wijzigen
Yes! If you want to change default printer you have to use the setprinter api func. Here is the sample:
oPD:= PrintingDevice{} IF opd:setup() SetDefaultPrinter(opd:Device,opD:GetDevMode()) rpt := rptmrsmain{SELF} //rptmrsmain - name of the report rpt:print({prm},range{1,2}) ENDIF
------------ Function SetDefaultPrinter(cPrinter As STRING, WinDevMode As _winDEVMODE) As Logic Local pInfo As _WinPrinter_Info_2 Local hPrinter As Ptr Local size As DWord Local ldone As Logic Local cPrn As String
IF OpenPrinter(String2Psz(cPrinter ), @hPrinter, NULL_PTR) GetPrinter(hPrinter, 2, NULL_PTR, 0, @size) pInfo := MemAlloc(size) IF GetPrinter(hPrinter, 2, pInfo, size, @size) pInfo.attributes := _Or(pInfo.attributes, PRINTER_ATTRIBUTE_DEFAULT) pInfo.pDevMode:= WinDevMode IF .not. (ldone := SetPrinter(hPrinter, 2, pInfo, 0)) // Win nt cPrn := Psz2String(pInfo.pPrinterName)+",winspool,"+Psz2String(pInfo.pPortName) WriteProfileString( String2Psz("windows"), String2Psz("device"),String2Psz(cPrn)) SendMessageTimeout( HWND_BROADCAsT, WM_WININICHANGE, 0L,0L,SMTO_NORMAL,1000, NULL) ldone := TRUE
ENDIF
ENDIF MemFree(pInfo) ClosePrinter(hPrinter) ENDIF RETURN ldone --------------------
I hope this help.
Regards
István Körmöndi
|