Hi if anybody could help I would appreciate it. I ?m trying to create a printpreview but it doesn?t  work this is what I do. I get the printer dc from printdlg. I create a bitmap ( createcompatiblebmp,printerdc,xres,yres.) then I create a memorydc createcompatibledc,printerdc. Now I select the bitmap into the devicecontext selectobject, memorydc,bitmap. Then I do the print routine substituting the memorydc for the printdc.

Is this the right way to do it?

Posted on 2005-08-15 02:46:33 by Draakie
Draakie,

Search here and the MASM32 site for author chib777, and package XXContols.  There was a recent translation from the original Russian postings that will probably be more helpful to you--unless you speak Russian.  I don't have the links right now, but with search you should have no trouble.  In the package is a preview and print, that I used for a Rich Edit Control.

hth,

farrier
Posted on 2005-08-15 09:05:20 by farrier
Thank you Farrier? :) but I 'm trying not to use rich edit. Here is my code:

Decidep proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
LOCAL MemDC : HDC
LOCAL WinDC : HDC
LOCAL XRes? : DWORD
LOCAL YRes? : DWORD

mov eax, uMsg
.if eax==WM_INITDIALOG
? ? mov yP,0
? ? ; Printer FONT
invoke lstrcpy, addr LFont.lfFaceName, addr FontMS
mov LFont.lfHeight, 12
mov LFont.lfWidth, 10
mov LFont.lfWeight, 100
invoke CreateFontIndirect, addr LFont
mov pFont, eax
? ? ; Printer DOCINFO
mov DOC.cbSize, SIZEOF DOC
mov DOC.lpszDocName, offset DocTitle
mov DOC.lpszOutput, NULL
mov DOC.fwType, NULL
? ? mov PDiag.lStructSize, SIZEOF PDiag
? ? m2m PDiag.hwndOwner, hWin
? ? m2m PDiag.hInstance, hInstance
? ? mov PDiag.nCopies,1
? ? mov PDiag.Flags, PD_RETURNDC OR PD_RETURNDEFAULT
invoke PrintDlg, offset PDiag
cmp eax, FALSE
jne Decide1
invoke MessageBox,hWin,addr Error12,addr ErrorD,MB_OK
invoke SendMessage,hWin,WM_CLOSE,NULL,NULL
jmp Decide4
Decide1:

? ? ;Printer X - Y
invoke GetDeviceCaps,PDiag.hDC,HORZRES
mov XRes, eax
shr eax, 3
mov ebx, 10
mov COLUMN_20,ebx
add ebx, eax
add ebx, eax
add ebx, eax
mov COLUMN_21,ebx
add ebx, eax
mov COLUMN_22,ebx
add ebx, eax
mov COLUMN_23,ebx
add ebx, eax
mov COLUMN_24,ebx
invoke GetDeviceCaps,PDiag.hDC,VERTRES
mov YRes, eax
mov LINE_WIDTH, 15
? .elseif eax==WM_CLOSE
invoke DeleteObject,pFont
invoke DeleteObject,hBit3
invoke DeleteDC,PDiag.hDC
? ? invoke EndDialog,hWin,0 ? ?
.elseif eax==WM_PAINT
invoke CreateCompatibleDC,PDiag.hDC
mov hDCPaint, eax
invoke CreateCompatibleBitmap,hDCPaint,XRes,YRes
mov hBit3, eax
invoke SelectObject,hDCPaint,hBit3

m2m hDCPrint, hDCPaint
;Spool Print
? ? invoke StartDoc,hDCPrint, offset DOC
? ? invoke SelectObject,hDCPrint, pFont
invoke StartPage,hDCPrint
? call PrintExch ; lots of Textout to hDCPrint
? invoke EndPage,hDCPrint
invoke EndDoc, hDCPrint

invoke BeginPaint,hWin,addr PStruc
mov WinDC, eax
invoke CreateCompatibleDC,WinDC
mov MemDC, eax
invoke SelectObject,MemDC,hBit3
invoke StretchBlt,WinDC,5,5,470,400,MemDC,0,0,XRes,YRes,WHITENESS
invoke EndPaint,hWin,addr PStruc


invoke DeleteDC, hDCPaint
invoke DeleteDC, MemDC
.elseif eax==WM_COMMAND
mov edx,wParam
movzx eax,dx
shr edx,16
.if eax==IDCANCEL
? ? ? ? invoke SendMessage,hWin,WM_CLOSE,NULL,NULL
? ? ? ? .endif? ? ?
.endif
Decide4:
xor eax, eax
ret
Decidep endp


This is not working!!!!!! 
I'm not sure if my program is righting to memdc and if the bitmap is changed. Can you maybe help?

Draakie
Posted on 2005-08-16 02:42:11 by Draakie