How do you code the CreateDC API for a printer in Windows XP?????
Printer is a Hewlett Packard All-in-one.

The CreateDC that works in Windows 98 doesn't work in XP.

Any help would be appreciated.

JPS
Posted on 2004-04-03 16:07:24 by shankle
Hi shankle

This is what I use to get the DC.

printdlg PRINTDLG <>


invoke RtlZeroMemory,addr printdlg,sizeof printdlg
mov printdlg.lStructSize,sizeof printdlg
push hWnd
pop printdlg.hWndOwner
push hInstance
pop printdlg.hInstance
mov printdlg.Flags,PD_RETURNDC ; opens printerdialog
; mov printdlg.Flags,PD_RETURNDC or PD_RETURNDEFAULT ; returns default printer DC
; without opening de printerdialog
mov printdlg.nCopies,1
invoke PrintDlg,addr printdlg

the printerDC will be returned in ----> printdlg.hDC

Good luck, SIEKMANSKI
Posted on 2004-04-04 05:03:59 by Siekmanski
Thank you very much for your code Siekmanski.
It didn't work but the PrintDlg is so complex I feel that I might
have some other setting wrong that's causing it to fail.
Still checking.
JPS
Posted on 2004-04-05 06:08:17 by shankle
Hi Shankle

I've made a printer test proggy for you.
So you can look at the source-code how it can be done.
It prints out some usefull printer device info and shows how to
use the GDI to draw a rectangle along the boundaries
of the printable area of the printer.
You can also choose a font and its color.

I hope this is usefull.

Greetings: SIEKMANSKI
Posted on 2004-04-05 09:01:22 by Siekmanski
Hi Siekmanski,
Got your first code to work. Must have corrupted my printer
software as when I reinstalled it your code started to work.
I changed one instruction though.
RtlZeroMemory to RtlFillMemory. PRINTDLG kept on harping
about NULL characters in fields so I put 0h in the 3rd parm.

Many Thanks,
JPS
Posted on 2004-04-05 13:35:45 by shankle