description | title | ms.date | helpviewer_keywords | ms.assetid | ||||
---|---|---|---|---|---|---|---|---|
Learn more about: Callback Functions Used by MFC |
Callback Functions Used by MFC |
11/04/2016 |
|
b2a6857c-fdd3-45ec-8fd8-2e71fac77582 |
Three callback functions appear in the Microsoft Foundation Class Library. These callback functions are passed to CDC::EnumObjects, CDC::GrayString, and CDC::SetAbortProc. Note that all callback functions must trap MFC exceptions before returning to Windows, since exceptions cannot be thrown across callback boundaries. For more information about exceptions, see the article Exceptions.
Callback Function for CDC::EnumObjects
Callback Function for CDC::GrayString
Callback Function for CDC::SetAbortProc
Header: afxwin.h
The ObjectFunc name is a placeholder for the application-supplied function name.
int CALLBACK EXPORT ObjectFunc(
LPSTR lpszLogObject,
LPSTR* lpData);
lpszLogObject
Points to a LOGPEN or LOGBRUSH data structure that contains information about the logical attributes of the object.
lpData
Points to the application-supplied data passed to the EnumObjects
function.
The callback function returns an int
. The value of this return is user-defined. If the callback function returns 0, EnumObjects
stops enumeration early.
The actual name must be exported.
OutputFunc is a placeholder for the application-supplied callback function name.
BOOL CALLBACK EXPORT OutputFunc(
HDC hDC,
LPARAM lpData,
int nCount);
hDC
Identifies a memory device context with a bitmap of at least the width and height specified by nWidth
and nHeight
to GrayString
.
lpData
Points to the character string to be drawn.
nCount
Specifies the number of characters to output.
The callback function's return value must be TRUE to indicate success; otherwise it is FALSE.
The callback function (OutputFunc) must draw an image relative to the coordinates (0,0) rather than (x, y).
The name AbortFunc is a placeholder for the application-supplied function name.
BOOL CALLBACK EXPORT AbortFunc(
HDC hPr,
int code);
hPr
Identifies the device context.
code
Specifies whether an error has occurred. It is 0 if no error has occurred. It is SP_OUTOFDISK if the Print Manager is currently out of disk space and more disk space will become available if the application waits. If code is SP_OUTOFDISK, the application does not have to abort the print job. If it does not, it must yield to the Print Manager by calling the PeekMessage
or GetMessage
Windows function.
The return value of the abort-handler function is nonzero if the print job is to continue, and 0 if it is canceled.
The actual name must be exported as described in the Remarks section of CDC::SetAbortProc.
Structures, Styles, Callbacks, and Message Maps
CDC::EnumObjects
CDC::SetAbortProc
CDC::GrayString