Re: setPrintJobProperty problem
- Posted by CChris <christian.cuvier at agriculture.??uv.fr> Oct 29, 2007
- 628 views
Andy Drummond wrote: > > Andy Drummond wrote: > > > > CChris wrote: > > > > > > Andy Drummond wrote: > > > > > > > > CChris wrote: > > > > > > > > > > > > > > > Since getPrinterChoice() displays a dialog box where the user might > > > > > change > > settings,</font></i> > > > > > it has to check for these changes and make them effective for the > > > > > printer. > > That's</font></i> > > > > > a fair amount of code indeed. > > > > > > > > > > > If so, should you add the getDefault Printer() to Win32Lib then I > > > > > > assume > > it</font></i> > > > > > > would set things up exactly the same as getPrinter()+OK does. Then > > > > > > it will > > > > > > work fine. I can wait; it is not a great pain like the press shift > > > > > > once > > pain.</font></i> > > > > > > > > > > > > > > > > The code I had posted was meant to be pasted in w32resources.ew, right > > > > > after > > > > > getPrinterChoice(). It will be in 70.2 anyway, probably with the > > > > > enhancements > > > > > suggested above. > > > > > > > > > > > Is it possible to call getPrinter() with an argument which tells the > routine</font></i> > > > > > > the printer name to get or even just to imitate the press of OK for > > > > > > the > > > > > > default printer? Something like (DOS days) pushing a keypress onto > > > > > > the > key</font></i> > > > > > > stack before calling a routine which then gets the keypress & > > > > > > returns > with</font></i> > > > > > > no user input needed. A thought.... > > > > > > > > > > I think I'd rather add a selectPrinter(objet printer) procedure. If > > > > > printer > > > > > is a sequence, it is a printer name string, and that will set > > > > > designated > printer</font></i> > > > > > as current printer. If name is unknown, fall back on > > > > > getPrinterChoice(). > How</font></i> > > > > > about that? > > > > > > > > > > > > > CChris, what you suggest is excellent; it would cover all cases beyond > > > > maybe > > > > having a routine which returns a list of the names of the printers > > > > available. > > > > Since I only want the default that is not something I'd ask for. Not > > > > yet! > > > > > > > > I am content to wait for your doing this as and when you get around to > > > > it; > > > > it will be a useful upgrade to my code so I can do a Microsoft Word and > > > > just > > > > > > > > have a button which prints all by itself. Magic. I can use > > > > setPrintJobProperty() > > > > to do lots now with just a single click to accept the printer choice. > > > > > > > > > > > > > > > > I appreciate your work on Win32Lib enormously - as I do Derek's work > > > > > > and > > > > > > I guess David Cuny's, who started it. You guys all want medals - or > > > > > > money > > -</font></i> > > > > > > but not being Bill Gates's, you will get users complaining their > > > > > > model > railway</font></i> > > > > > > won't work right under Win32Lib or their printer keeps running out > > > > > > of ink > > or</font></i> > > > > > > something silly like that. > > > > > > > > > > > > Tough life, isn't it. You do have many fans, though! > > > > > > > > > > > > AndyD > > > > > > > > > May I comment; when I said you guys all want medals etc, I meant DESERVE > > > > medals > > > > not want as in desire.... no offence meant. > > > > > > > > > > > > > > I expect more complaints about printing for the weeks ahead actually. > > > > > The lib had just so many print features that were offered, but didn't > > > > > work. > > > > > As some start to, there will be more voices to ask for everything to > > > > > work > right</font></i> > > > > > out of the box, and I cannot test everything because I have one > > > > > computer > and</font></i> > > > > > two printers only (a laser and AdobePDF). That's why having a good > > > > > pool of > > testers</font></i> > > > > > to catch issues before release would tremendously help. > > > > > > > > > > CChris > > > > > > > > Hopefully not too many complaints - just helpful criticism as we try and > > > > do > > > > our job as testers. But it does sound like complaining to me though it > > > > is > > > > not meant that way.. > > > > > > > > AndyD > > > > > > Replace at line 1272 in w32resources.ew the text for getDefaultPrinter() > > > by: > > > }}} <eucode> > > > --/topic Printing > > > --/func getDefaultPrinter() > > > --/desc Like /getPrinter(), but assumes there is a default printer already > > > installed > > > --/ret (ATOM) DC for default printer > > > global function getDefaultPrinter() > > > printerDC = w32Func(xCreateDC,{wsp,pname,0,0}) > > > setPrinterPointers(1) > > > return printerDC > > > end function > > > </eucode> {{{ > > > > > > Then, calling setPrintJobProperty() should update everything, but most > > > importantly > > > the printer itself. Let us know whether this is working better. > > > > > > CChris > > > > Line 1212 seems better - 1272 is in the middle of startPage(). I have put in > > the new version of getDefaultPrinter() code and I'll try it ASAP. Maybe it > > is > > just the testing version of Win32Lib I have now got. > > > > AndyD > > I just tried this but it seems no better. Here is the code I'm using; it > outputs in portrait mode to the printer. > > }}} <eucode> > -- code generated by Win32Lib IDE v1.1.0 Build Oct-07-2007 > > constant TheProgramType="exw" > > include Win32Lib.ew > without warning > > > -------------------------------------------------------------------------------- > -- Window Window1 > constant Window1 = createEx( Window, "Window1", 0, Default, Default, 400, 300, > 0, 0 ) > constant PushButton2 = createEx( PushButton, "Print", Window1, 180, 120, 90, > 30, 0, 0 ) > --------------------------------------------------------- > > > -------------------------------------------------------------------------------- > procedure PushButton2_onClick (integer self, integer event, sequence > params)--params is () > VOID = getDefaultPrinter() > -- VOID = setPrintJobProperty(JP_Orientation, DMORIENT_LANDSCAPE) > VOID = startDoc("fred") > VOID = startPage() > VOID = setPrintJobProperty(JP_Orientation, DMORIENT_LANDSCAPE) > wPuts(Printer, "This is output on the default printer!") > VOID = endPage() > VOID = endDoc() > releasePrinter() > abort(0) > end procedure > setHandler( PushButton2, w32HClick, routine_id("PushButton2_onClick")) > > > WinMain( Window1,Normal ) > </eucode> {{{ > > Have I done something particularly daft? If not, have we any ideas? > AndyD Expected. Add the setPrinterPointers(1) call in getDefaultPrinter() and try it again. CChris