The following print program works find on Windows 98.
Friend 1 has Windows XP with a lexmark printer. The Print data comes
out with a 60% reduction in size.

Friend2 has Windows XP with a Photo XP printer and the data comes out
horizontal with a 20% increase in size.

Any pointers would be appreciated.
Posted on 2002-10-21 18:34:32 by shankle
Hi, I will tell you my experience with your small proggy.

I installed it and configured Visual Studio etc, and when I executed it, I got a processor fault.

I stepped thru the program and found that the offending line was the one containing the rectangle call. Then I restarted the app and stopped execution on the line following the printer enumeration call, and after noting that the printer the app was trying to use was the fax driver "Comunicate 32", I manually changed the printer name to "EPSON Stylus Photo 700", and that fixed the processor fault problem, but not completely: nothing happened.

So I changed the flag in the printer enumeration call to enumerate default printers, and now the Epson printer was being selected by default, but now the app just runs and displays the main window and quits on the key, bot nothing else happens.

So after more than 3 years of no even looking at the Windows API printing services, I remembered that you need to call StartDoc/EndDoc and StartPage/EndPage as apropriate, and you are not doing that in your proggy. So I added those calls and guess what? That fixed both problems!

I used a Pentium III 800Mhz, Windows 98 (first edition), and Comunicate 32 "printer" driver (the fax-modem), and a Epson Stylus Photo 700.

It seems printer drivers can exibit all kinds of behavior when the calls to Start/End Doc/Page are missing, anything from "nothing happens" to your printer driver diying a miserable death and bringing down your app with it.

Aparently you Lexmark driver is forgiving and will call StartDoc/Page for you on your first print command, and then EndPage/Doc when the device context is destroyed, similarly to the way Visual Basic works (althought if I remenber correcly, you need to manually call a function to the effect of EndPage and/or EndDoc), but not so on other printer brands. So just add those missing calls and I think the problem will go away on your friends' XP boxes.

Later...
Posted on 2002-10-23 08:12:21 by CarlosM7
Thank you so much Carlosm7.
I will try your suggestions.

Can't believe I left out startdoc or startpage.

Thanks again
Posted on 2002-10-23 09:57:19 by shankle
Good work Carlos :)


shankle,
here is something else for you to think about: enumerating printers may have to be done differently under the different OSs, depending on what you are looking for. I last played with this a couple of years ago, and found markedly different behaviour depending on whether the OS was 9x or NT based, and whether you were part of a network or not. So if you are going to release your app, test carefully :)
Posted on 2002-10-24 01:47:16 by sluggy