DIB Screen Capture/Printing API Specification By Pat Schreiber and Mark Bader Version dated October 8, 1991 Copyright (c) 1991 Microsoft Corporation. All rights reserved. PrintWindow Syntax WORD PrintWindow(hWnd, fPrintArea, fPrintOpt, wXScale, wYScale, szJobName) This function prints an entire window or its client area on the current default printer. Banding is used if the printer driver supports it. Parameter Type/Description hWnd HWND Specifies the window to be printed. fPrintArea WORD Specifies the area(s) of the window to be printed. See below for a listing of the possible values for this parameter. fPrintOpt WORD Species the printing options. See below for a listing of the possible values for this parameter. wXScale WORD Specifies the x-axis scaling factor for the printed window. The x and y scaling factors are only used if the PW_SCALE option below is selected. wYScale WORD Specifies the y-axis scaling factor. szJobName LPSTR Specifies the name of the print job. This string is used in the job name sent to the print spooler, as well as in the print dialog box. The fPrintArea parameter must be set to one of the following: Value Meaning PW_WINDOW Print the entire window. PW_CLIENT Print the client area of the window. The fPrintOpt parameter must be set to one of the following: Value Meaning PW_BESTFIT Fits the printed screen on the page in as large of a area as possible while still retaining the correct screen aspect ratio. The wXScale and wYScale parameters are not used if this option is selected. This is the default value. PW_STRETCHTOPAGE Stretches the printed screen to fill up the entire printed page. The wXScale and wYScale parameters are not used if this option is selected. PW_SCALE Scales the printed screen by the integer scaling factors specified in the wXScale and wYScale parameters. If the scaling is set too large, the screen may extend off the printed page and will be clipped. Return Value 0 if successful, or one of: ERR_DIBFUNCTION, ERR_INVALIDHANDLE, ERR_LOCK, ERR_SETABORTPROC, ERR_STARTDOC, ERR_NEWFRAME, ERR_ENDDOC, ERR_GETDC, ERR_STRETCHDIBITS. These constants are defined in errors.h. PrintScreen Syntax WORD PrintScreen(rRegion, fPrintOpt, wXScale, wYScale, szJobName) This function prints the specified area of the screen on the default printer. Parameter Type/Description rRegion LPRECT Specifies the region of the screen (in screen coordinates) to be printed. To print the entire screen, set this rect to encompass the entire screen. fPrintOpt WORD Species the printing options. wXScale WORD Specifies the x-axis scaling factor for the printed window. The x and y scaling factors are only used if the PW_SCALE option below is selected. wYScale WORD Specifies the y-axis scaling factor. szJobName LPSTR Specifies the name of the print job. This string is used in the job name sent to the print spooler, as well as in the print dialog box. Return Value 0 if successful, or one of: ERR_DIBFUNCTION, ERR_INVALIDHANDLE, ERR_LOCK, ERR_SETABORTPROC, ERR_STARTDOC, ERR_NEWFRAME, ERR_ENDDOC, ERR_GETDC, ERR_STRETCHDIBITS. These constants are defined in errors.h. CopyWindowToDIB Syntax HDIB CopyWindowToDIB(hWnd, fPrintArea) This function copies the specified part of the window to a device-independent bitmap. Parameter Type/Description hWnd HWND Specifies the window. fPrintArea WORD Specifies the window area(s) to copy into the device- independent bitmap. Return Value The value returned identifies the device- independent bitmap if the function is successful. Otherwise, it is NULL. CopyScreenToDIB Syntax HDIB CopyScreenToDIB(lpRect) This function copies the specified part of the screen to a device-independent bitmap. Parameter Type/Description lpRect LPRECT Pointer to a RECT data structure that contains the rectangle to be copied. Return Value The value returned identifies the device- independent bitmap if the function is successful. Otherwise, it is NULL. CopyWindowToBitmap Syntax HBITMAP CopyWindowToBitmap(hWnd, fPrintArea) This function copies the specified part of the window to a device-dependent bitmap. Parameter Type/Description hWnd HWND Specifies the window. fPrintArea WORD Specifies the window area(s) to copy into the device- independent bitmap. Return Value The value returned identifies the device- dependent bitmap if the function is successful. Otherwise, it is NULL. CopyScreenToBitmap Syntax HBITMAP CopyScreenToBitmap(lpRect) This function copies the specified part of the screen to a device-dependent bitmap. Parameter Type/Description lpRect LPRECT Pointer to a RECT data structure that contains the rectangle to be copied. Return Value The value returned identifies the deice- dependent bitmap if the function is successful. Otherwise, it is NULL. PrintDIB Syntax WORD PrintDIB(hDib, fPrintOpt, wXScale, wYScale, szJobName) This function prints the specified DIB. Parameter Type/Description hDib HDIB Specifies the handle to a DIB which is to be printed fPrintOpt WORD Specifies the printing option. wXScale WORD Specifies the x-axis scaling factor for the printed window. The x and y scaling factors are only used if the PW_SCALE option is selected for the fPrintOpt parameter. wYScale WORD Specifies the y-axis scaling factor. szJobName LPSTR Specifies the name of the print job. This string is used in the job name sent to the print spooler, as well as in the print dialog box. Return Value 0 if successful, or one of: ERR_INVALIDHANDLE, ERR_LOCK, ERR_SETABORTPROC, ERR_STARTDOC, ERR_NEWFRAME, ERR_ENDDOC, ERR_GETDC, ERR_STRETCHDIBITS. These constants are defined in errors.h. SaveDIB Syntax WORD SaveDIB(hDib, lpFileName) This function saves the specified DIB to a disk file in Windows 3.0 DIB format. Although the convention for naming DIB files is to use a .BMP extension, the entire file name must be specified. Parameter Type/Description hDib HDIB Specifies the handle to a DIB which is to be saved. lpFileName LPSTR Specifies the complete path name of the DOS filename under which this DIB is to be saved. Return Value The value returned is zero for success or an error code of one of the following: ERR_INVALIDHANDLE, ERR_OPEN, or ERR_LOCK. LoadDIB Syntax HDIB LoadDIB(lpFileName) This function loads a DIB from the specified file, allocates memory for the DIB, and returns a handle to the DIB. Parameter Type/Description lpFileName LPSTR Specifies the complete path name of the DOS filename of the DIB to load. This function will load files with any extension, but the convention is to name DIB files with a .BMP etension. Return Value The value returned identifies the deice- dependent bitmap if the function is successful. Otherwise, it is NULL. DestroyDIB Syntax WORD DestroyDIB(hDib) This function destroys the specified DIB, deleting any memory associated with the DIB. The handle to the DIB is invalid after calling this function. Parameter Type/Description hDib HDIB Specifies the handle to the DIB to destroy. Return Value The value returned is zero for success.