Link to home
Start Free TrialLog in
Avatar of gandalf3373
gandalf3373

asked on

printer device context resolution

hello, i have an application that renders an openlg context to a dibsection, and this is in turn printed on a printer from a dib. everything works great but the problem is that i want to specify 300 dpi as the output resolution on the printer's device context. there must be a way to set this, i have done it in other applications (printes out at 300 dpi that is, but i did not write the code). can anyone tell me how to set the resolution? i know i can get the current resolution with GetDeviceCaps and LOGPIXELSY, and LOGPIXELX. what i want to be able to do is set these values to 300, or by some other way set the output resolution of the device context. i want to be able to create my image such that it will always print out at 300 dpi. the only thing i cannot figure out how to do after researching is how i can explicitly set the output resolution of the printed page, provided of course the printer can handle it.

thanks,
james
Avatar of Zoppo
Zoppo
Flag of Germany image

Hi gandalf3373,

I'm not sure (since I didn't use this up to now), but I think you can do this
with OpenPrinter() and DocumentProperties() ... see MSDN about their usage.

Hope this helps,

ZOPPO

BTW, just for interest: What do you want to do if the used printer doesn't support 300 DPI?
Avatar of gandalf3373
gandalf3373

ASKER

zoppo,

i have narrowed it down to the DEVMODE structure that returns with the PRINTDLG structure. perhaps i should not be posting this in MFC but rather in the windows programming section, since the routine is mostly sdk code. but anyways, i have tried changing the fields before printing it out but it is not working. i am still stuck at the user defined resolution. as far as the printer not supporting 300 dpi, i have a backup that will print it out at the resolution which is less than 300, whatever that is depending upon the return value of GetDeviceCaps. so still if anyone knows how to properly change the DEVMODE structure returned when the printdlg returns let me know. that would solve my problem very easily. the only two fields i want to set are dmPrintQuality and dmYResolution.

i have tried this

DEVMODE* customDeviceMode = (DEVMODE*)GlobalLock(pd.hDevMode);
            customDeviceMode->dmPrintQuality = 300;
            customDeviceMode->dmYResolution  = 300;

i do not get any errors, but it does not print out at 300 dpi either. i am testing this on a printer that defaults to 600.

james
300 is not a print quality setting.  The constants for dmPrintQuality are

#define DMRES_DRAFT         (-1)
#define DMRES_LOW           (-2)
#define DMRES_MEDIUM        (-3)
#define DMRES_HIGH          (-4)
Er, as I was trying to say before my computer rebooted, you also need to set the dmFields to with the flags for DM_PRINTQUALITY (not really needed since the default is horz and vert being the same) and DM_YRESOLUTION.

Hope this helps.
dmPrintQuality
Specifies the printer resolution. There are four predefined device-independent values:
DMRES_HIGH
DMRES_MEDIUM
DMRES_LOW
DMRES_DRAFT

If a positive value is given, it specifies the number of dots per inch (DPI) and is therefore device dependent.
---------------------------------------------------------------------------------------------------------------------------------

that is from the docs. i was wondering if that meant that by specifying a non-negative value, i would be explicitly be setting the dpi. i have tried the constants and those are not working either, so maybe it is the way i am setting it? i do not know.

james
Well, if setting dmFlags didn't work, are you sure you are fllwoing all the steps properly: http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q167/3/45.asp&NoWebContent=1

If you really are doing all those steps and it still doesn't work, I don't know what would be doing it.
Whoops, I mean if setting *dmFields with the flags* didn't work.
SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks guys. i have not gotten anything to work yet but i am working on it today, i implemented the last link that KurtVon posted on friday afternoon but that is not working either. i will let u guys know when i get it working. again though with everything i have tried, i have my image printing out, i just cannot get it to print out at code-specified resolution.

james
i have tried all of the suggestions and it is just not working. maybe i would be better off trying postscript in the future. anyways, after all of the trouble i have just decided to match the image to the resolution that the user selects from the print dialog or the default. which works good and i had to do that anyways if the printer did not suppoort 300 dpi. i would have rathered kept it at 300dpi max though since that was all that was really necessary to get a nice quality image, which could save some processing and memory.

i did however get everything i tried to work in the code i guess, i was not getting any errors, the resolution was simply just not changing. it could have been the printers i was testing on anyways, because the testing with the dmFlags never even allowed the changing of the dmYResolution.


thanks,
james