9-4-2012
for a 32-bit program
This is what I found after the above tests
Testing of CREATEDC shows that hdcPrn was created correctly
Testing of STARTDOC with hdcPrn executed correctly
Testing of STARTPAGE with hdcPrn executed correctly
Testing of CreateFontA executed correctly
Testing of SelectObject with hdcPrn gave an error. Invalid handle
I have executed a DeleteObject on all other uses of SelectObject
DATA SECTION
dwNeeded dd 0
dwReturned dd 0
holdright dd 0
holdbottom dd 0
PrintCString db 96 DUP 0 ; buffer to receive the printer name
WndProc:
FRAME hWnd,uMsg,wParam,lParam
USES ebx,edi,esi
Local hMemory,ps:PAINTSTRUCT,hdc,hdcPrn,DI:DOCINFO
.WM_CREATE
cmp D[uMsg],WM_CREATE
jne >>.WM_CHAR
push ebx
invoke EnumPrinters, PRINTER_ENUM_LOCAL,NULL,4,NULL,\
0,addr dwNeeded,addr dwReturned
invoke GlobalAlloc, GHND,[dwNeeded]
mov [hMemory], eax
invoke GlobalLock, eax
;? mov [pinfo4],eax
invoke EnumPrinters, PRINTER_ENUM_LOCAL,NULL,4,addr PrintCString,\
[dwNeeded],addr dwNeeded,addr dwReturned
mov ebx,addr PrintCString
mov edx, [ebx+PRINTER_INFO_4.pPrinterName]
invoke CreateDC, NULL,edx,NULL,NULL
mov [hdcPrn],eax
;? mov [hdc],eax
invoke GlobalUnlock, [hMemory]
invoke GlobalFree, [hMemory]
; invoke SystemParametersInfoA, SPI_GETWORKAREA,0,addr rc,0
; holdright/holdbottom are filled by the SystemParametersInfoA api.
invoke Rectangle, [hdc],0,0,[holdright],[holdbottom]
pop ebx
ret
; other code
mov eax, SIZEOF DOCINFO ; fill in fields of the DOCINFO Struct
mov [DI.cbSize],eax
mov eax,addr AppName
mov [DI.lpszDocName], eax
mov D[DI.lpszOutput],NULL
mov D[DI.lpszDatatype],NULL
mov D[DI.fwType],0
invoke StartDoc, [hdcPrn],addr DI
invoke StartPage, [hdcPrn]
invoke CreateFontA, 200,74,0,0, FW_SEMIBOLD, FALSE,FALSE,FALSE, \
DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, \
PROOF_QUALITY, FF_DONTCARE, addr szTimesNR
mov [hNFont], eax
invoke SelectObject,[hdcPrn],[hNFont] ;(TESTED BAD)
push eax
; othercode
ENDF