views:

44

answers:

1

Hi,

Does anybody know the "magic trick" for printing gray lines in an MFC/VS6 based application, using the PS_SOLID style?

It works when printing to PDF, but I just get black lines when printing to my black/white laser printer. It also works with the PS_INSIDEFRAME style, but it seems strange to me that a normal PS_SOLID can't do gray

Here's how the CPen is setup: CPen linePen(PS_SOLID, 50, RGB(128,128,128));

I am using the MoveTo/LineTo functions for drawing.

Thanks!

  • Fabian
A: 

Are you sure the printer context is set correctly, i.e. that you don't have a bit depth of 1?

Roel
Sorry for huge delay. The printer DC indeed has a bit depth of 1 (according to the device caps). I noticed that the DEVMODE provides a BitsPerPixel, but am not sure when I am supposed to set this (and to which value - probably depends on the printer). Any hints?
Fabian
You get the printer capabilities from the printer configuration dialog. See a tutorial on printing with MFC for examples. I don't have any code at hand here, but IIRC it comes down to you getting a complete DEVMODE struct from the printer settings dialog, and using that one to create a device to print to. Most of this is boiler plate code that you should copy from MFC examples (I think there's a printing example in the MFC samples, too, actually I'm sure there is.)
Roel