Hi,
I've seen this function (look the subject) (a question from Jimmy Clif about preview). But I can't use it, I don't in which include file it is, in fact I did a search and I've found this function nowhere.
Where can I find the files needed.
Thanks...
Searched the Feb 2001 SDK and could not find such a function.
Here is what I did find in the Windows GDI section...
Printer Output
Just as an application requires a display device context (DC) before it can begin drawing in the client area of a window, it needs a printer DC before it can begin sending output to a printer. A printer DC is similar to a display DC in that it is an internal data structure that defines a set of graphic objects and their associated attributes and specifies the graphic modes that affect output. The graphic objects include a pen (for line drawing), a brush (for painting and filling), and a font (for text output).
Unlike a display DC, printer DCs are not owned by the window management component, and they cannot be obtained by calling the GetDC function. Instead, an application must call the CreateDC or PrintDlgEx function.
If you call the CreateDC function, you must supply a driver and port name. To retrieve these names, call the GetPrinter or EnumPrinters function.
If your application calls the PrintDlgEx function and specifies the PD_RETURNDC value in the Flags member of the PRINTDLGEX structure, the system returns a handle to a device context for the printer selected by the user. For more information, see Print Property Sheet and Using the Print Property Sheet.
Microsoft® Windows® 95, Windows 98, and Microsoft Windows NT® versions 4.0 and earlier do not support the PrintDlgEx function. If your application needs to run on these platforms, use the PrintDlg function with the PD_RETURNDC value. For more information, see Print Dialog Box and Displaying the Print Dialog Box.
Hi,
Could Jimmy Clif or forge answer this question because they've spoken about "GetPrinterDC" for print preview.
Thanks.
Vom-bonjour:-()
This is easy to explain.
GetPrinterDC proc uses ebx
LOCAL dwNeeded:DWORD
LOCAL dwReturned:DWORD
LOCAL hdc:HDC
invoke GetVersion ; No parameters reqd
.if eax & 80000000h ; If high bit's set then its Win95/98
; ; **** If here, its Win95/98 ****
invoke EnumPrinters, PRINTER_ENUM_DEFAULT, 0, 5, 0, \
0, ADDR dwNeeded, ADDR dwReturned ; Find how much memory we need (dwNeeded)
; Use GlobalAlloc instead of malloc to allocate memory; eax returns handle to memory
invoke GlobalAlloc, GMEM_MOVEABLE or GMEM_ZEROINIT, dwNeeded
mov hMemory, eax
invoke GlobalLock, eax ; Lock the memory block & return pointer to memory
mov pinfo5, eax ; Save it
mov ebx,eax ; Set reg to memory
invoke EnumPrinters, PRINTER_ENUM_DEFAULT, 0, 5, pinfo5, \
dwNeeded, ADDR dwNeeded, ADDR dwReturned
invoke CreateDC, 0, PRINTER_INFO_5.pPrinterName, 0, 0
mov hdc,eax
invoke GlobalUnlock, pinfo5 ; Invalidate pointer to memory block
invoke GlobalFree, hMemory ; Free the memory
.else ; **** Else its Windows NT ****
invoke EnumPrinters, PRINTER_ENUM_LOCAL, 0, 4, 0, \
0, ADDR dwNeeded, ADDR dwReturned
invoke GlobalAlloc, GMEM_MOVEABLE or GMEM_ZEROINIT, dwNeeded
mov hMemory, eax
invoke GlobalLock, eax ; Lock the memory block & return pointer to memory
mov pinfo4, eax ; Save it
mov ebx,eax
invoke EnumPrinters, PRINTER_ENUM_LOCAL, 0, 4, pinfo4 , \
dwNeeded, ADDR dwNeeded, ADDR dwReturned
invoke CreateDC, 0, PRINTER_INFO_4.pPrinterName, 0, 0
mov hdc,eax
invoke GlobalUnlock, pinfo4 ; Invalidate pointer to memory block
invoke GlobalFree, hMemory ; Free the memory
.endif
mov eax, hdc
ret
GetPrinterDC endp
forge