News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Printing a DC

Started by Farabi, May 21, 2010, 10:01:18 PM

Previous topic - Next topic

Farabi

I created this function

fPrintDC proc hWnd:dword,hDC:dword
LOCAL p: PRINTDLG
LOCAL _di:DOCINFO
LOCAL p2:PRINTDLG
LOCAL prx,pry:dword
LOCAL b:BITMAP
LOCAL buff[256]:dword
LOCAL p_dim:POINT
LOCAL p_dim2:POINT

.if hDC==0
ret
.endif

invoke memfill, addr _di,sizeof DOCINFO,0
mov _di.cbSize,sizeof DOCINFO
lea eax,fnm
mov _di.lpszDocName,eax
mov _di.lpszOutput,0
mov _di.lpszDatatype,0
mov _di.fwType,0

invoke memfill, addr p2,sizeof PRINTDLG-4,0
mov p2.lStructSize,sizeof PRINTDLG
mov p2.Flags,PD_RETURNDC
invoke PrintDlg,addr p2
.if eax!=0
.if p2.hDC==0
invoke MessageBox,0,CADD("Printer DC is wrong"),0,0
.endif

invoke GetDeviceCaps,p2.hDC,VERTRES
mov p_dim.x,eax
invoke GetDeviceCaps,p2.hDC,HORZRES
mov p_dim.y,eax

invoke GetDeviceCaps,hDC,VERTRES
mov p_dim2.x,eax
invoke GetDeviceCaps,hDC,HORZRES
mov p_dim2.y,eax


invoke StartDoc,p2.hDC,addr _di
.if eax==SP_ERROR
invoke MessageBox,0,CADD("Cannot start, document"),0,0
.endif

invoke StartPage,p2.hDC
.if eax<=0
invoke MessageBox,0,CADD("Cannot start printer"),0,0
.endif

invoke StretchBlt,p2.hDC,0,0,p_dim.x,p_dim.y,hDC,0,0,p_dim2.x,p_dim2.y,SRCCOPY
;invoke BitBlt,p2.hDC,0,0,p_dim.x,p_dim.y,hDC,0,0,SRCCOPY


invoke EndPage,p2.hDC
invoke EndDoc,p2.hDC

invoke DeleteDC,p2.hDC

.endif


ret
fPrintDC endp


But I does not work well. I can print it but there are border at the half of the paper. How to make it fit into paper.
The DC I print had a resolution 1024x768.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"