set procedure to getbininfo.cc set procedure to papersize.prg ** END HEADER -- do not remove this line // // Generated on 15-08-2020 // parameter bModal local f f = new set_iniForm() if (bModal) f.mdi = false // ensure not MDI f.readModal() else f.open() endif class set_iniForm of FORM with (this) onOpen = class::FORM_ONOPEN height = 20.5909 left = 51.5714 top = 0.0 width = 104.4286 text = "" endwith this.TEXT1 = new TEXT(this) with (this.TEXT1) height = 1.0 left = 1.0 top = 4.5 width = 33.0 text = "Please Select the Printer name" endwith this.PRINTER_NAME = new COMBOBOX(this) with (this.PRINTER_NAME) onChangeCommitted = class::PRINTER_NAME_ONCHANGECOMMITTED height = 1.0 left = 43.0 top = 4.5 width = 34.0 style = 2 // DropDownList endwith this.TEXT2 = new TEXT(this) with (this.TEXT2) height = 1.0 left = 1.0 top = 1.0 width = 33.0 text = "Please Enter the INI File name" endwith this.INI_NAME = new ENTRYFIELD(this) with (this.INI_NAME) height = 1.0 left = 43.0 top = 1.0 width = 26.0 value = " " endwith this.TEXT3 = new TEXT(this) with (this.TEXT3) height = 1.0 left = 1.0 top = 6.4545 width = 33.0 text = "Please Select the Paper size" endwith this.PAPER_SIZE = new COMBOBOX(this) with (this.PAPER_SIZE) height = 1.0 left = 43.0 top = 6.4545 width = 34.0 style = 2 // DropDownList endwith this.TEXT4 = new TEXT(this) with (this.TEXT4) height = 1.0 left = 1.4286 top = 8.4091 width = 33.0 text = "Please Select the Paper Bin" endwith this.PAPER_BIN = new COMBOBOX(this) with (this.PAPER_BIN) height = 1.0 left = 43.4286 top = 8.4091 width = 34.0 style = 2 // DropDownList endwith this.SAVE_INI = new PUSHBUTTON(this) with (this.SAVE_INI) onClick = class::SAVE_INI_ONCLICK height = 1.0909 left = 15.0 top = 11.5 width = 15.2857 text = "&Save Ini File" endwith function PRINTER_NAME_onChangeCommitted() if not empty(form.printer_name.value) local x x = new getBINinfo(form.printer_name.value,'0') if x.aBinNames.size >0 pap_bins = 'array {' for i = 1 to x.aBinNames.size if i >1 pap_bins+=[,] endif pap_bins+=["]+x.aBins[i]+ [-]+x.aBinNames[i]+["] endfor pap_bins+=[}] form.paper_bin.enabled = true form.paper_bin.datasource = pap_bins form.paper_bin.value = x.aBins[1]+ [-]+x.aBinNames[1] else form.paper_bin.datasource =[array {"No bins found"}] form.paper_bin.value = "No bins found" form.paper_bin.enabled = false endif pap_sizes = 'array {' for i = 1 to x.aSourceNames.size if i >1 pap_sizes+=[,] endif pap_sizes+=["]+x.aSources[i]+ [-]+x.aSourceNames[i]+["] endfor form.paper_size.datasource = pap_sizes + [}] form.paper_size.value = x.aSources[1]+ [-]+x.aSourceNames[1] endif return function SAVE_INI_onClick() if not empty(form.ini_name.value) of = new file() // of.create(rtrim(ltrim(form.ini_name.value))+".ini") // of.writeln("color[N]"+r.printer.color) // of.writeln("duplex[N]"+r.printer.duplex) // of.writeln("orientation[N]"+r.printer.orientation) // of.writeln("papersize[N]"+r.printer.papersize) // of.writeln("papersource[N]"+r.printer.papersource) // of.writeln("printername[C]"+r.printer.printername) // of.close() endif return function form_onOpen() //basic code of getting printer names copied from selprinter.cc of duflp avprinters = new array() data_source = 'array {' x = new OleAutoClient("WScript.Network") oPrinters = x.EnumPrinterConnections() for i = 0 to oPrinters.count() -1 step 2 if len(data_source) >8 data_source = data_source+[,] endif data_source = data_Source+ ["]+oPrinters.Item(i+1) + ["] next i data_source = data_source + [}] form.printer_name.datasource = data_source initexterns() form.printer_name.value = getprinterdefault() form.printer_name_onchangecommitted() return endclass