class CCorepreviewCallbackWrapper
This class is a top-level wrapper for COREPREVIEW_CALLBACK
structure.
Member variables
-
m_hPreviewWindow
- handle of the preview window
-
m_pCorePreviewCallback - pointer to COREPREVIEW_CALLBACK
structure
-
m_PrintDocumentName - the string contains the name of the
document and is used by default implementation of CcwGetPrintDocName()
virtual function.
Member functions
All member functions can be splitted into several groups:
-
Virtual functions
- these virtual functions are used as handlers of events which happens in the
preview window
-
Notification functions
- these functions are used by preview window to report events to client.
-
Static functions - this set of functions is
used to route calls from a Cm function to the corresponding
Ccw
function
-
Command functions - they are used to get or
set some information from the preview window, to give a command etc
Virtual functions
Most of the virtual functions start from the prefix Ccw.
To get some functionality of the class you have to overload a few of them,
which ones depend on your needs. Below is the list of virtual functions:
-
void CcwForwardMessage(HWND hWnd, UINT msg,
WPARAM wParam, LPARAM lParam) - this function
is called every time when a message comes to the preview window. Because
message forwarding is very time consuming deal by defaut the forwarding is
turned off. To enable forwarding please use DoEnableMessageForwarding
member function (see below). msg, wParam, lParam are clear,
the only parameter which needs to be explained is the hWnd.
hWnd is the handle of the preview window ( in case you use frame
preview window this is not the handle of the frame preview window but
the handle of preview window that is inside the frame). This is the same handle
which DoGetCorePreviewWindowHandle
function returns
-
void CcwDrawPage (HDC dc, DWORD Page,
DWORD Print,LPRECT lpRect) - this function is
called every time when a page needs to be redrawn. dc is the
handle of the device context. The coordinate space
of the dc has been set. Page is the number of
page, first page has the number 0. Print is the flag which shown whether page
is being drawn on the screen or on a printer/to a file. Zero means screen,
nonzero - printer or file. lpRect
is a pointer to RECT structure which contains bounds of invalid rectangle
on the page (sizes are given in page's coordinates)
-
void CcwMouseMove(LONG x, LONG y,
LONG Page, LONG TotalPages) - this function
is called every time when mouse moves over the window. x, y -
logical coordinates of the pointer, Page - the number of page
on which the pointer is or, when the pointer is out of page, CURSOR_NOT_ON_PAGE.
Total pages
is the number of pages
-
void CcwPreviewModeChanged(COREPREVIEW_MODE mode,
float fZoom) - when preview mode has changed the function
is called
-
LONG CcwWindowIsAboutToClose() - this function is only
called when frame preview window is used. It means that user tries to close
window. The return value of the functions determines whether the window will be
closed. Nonzero means that the window will be closed, zero - the window should
be
-
void CcwNcDestroy(HWND hWnd) - this function
is called once, when preview window receives WM_NCDESTROY message.
This handler is a good place to free all resources associated with this
instance of preview window. See Elementary
example application as the example of usage of this function
-
LPCTSTR CcwGetPrintDocName() - this function is called when
user prints the document to a printer. The purpose of the function is to return
the name of the document, which will be seen in the printer spooler window
while the document is being printed. The default implementation of the function
returns the pointer to the m_PrintDocumentName member variable
which can be set by using of DoSetDocumentName
function
-
void CcwStartPrint(HDC hdc,LPCTSTR pszPrinterName
) - this function is called when printing is started. hdc is
the handle of printer and pszPrinterName is the name of
printer. When printing is made to raster image file or EMF file, the name of
the printer will be BESTVIEW_RASTER_OUTPUT_PRINTER_NAME or
BESTVIEW_EMF_OUTPUT_PRINTER_NAME
-
void CcwEndPrint() - this function is called when printing
has been finished
-
LONG CcwBeforePrint(HWND hwnd,LPCTSTR pszPrinterName,PDEVMODE
pDevMode) - this function is called when the user
clicks Print button, but before printing actually
starts. This is the last chance for developer to change the given (pszPrinterName)
printer's settings (pDevMode) or even cancel printing. The
return value of this callback function indicates whether the printing should
start, nonzero means print, zero means cancel
Also these is one special virtual function: void ViPostCreatePreview().
This function is called after the preview wndow's creation. You can
override it to add functionality you need.
Notification functions
These functions are used by preview window to report events to client. Functions
starts from the prefix Cm. Any call of such function causes
call of the corresponding Ccw function. End user usually don't
need to use these functions.
Static functions
This set of functions is used to route calls from a Cm function
to the corresponding Ccw function. Names of these function are
prefixed by tplfn. In the constructor of CCorepreviewCallbackWrapper
class its members, pfn pointers to functions, are initialized
by pointers to tplfn functions (also see DoEnableMessageForwarding
function description).
Command functions
They are used to get or set some information from the preview window. There are
two sets of command functions: Di and Do.
Di functions operate with a handle of a preview window, Do
functions work using Di set and use the handle of the current
preview window, which is stored in the m_hPreviewWindow member
variable. Below is the list of Do and Di functions:
-
LONG DoCorepreviewPrintToEmf
() - prints the content to a set of EMF files
-
LONG DoCorepreviewPrintToBitmap
() - prints the content to a set of jpeg or bitmap files
-
LONG DoCorepreviewPrint(LPCTSTR pszFileName=0,LPCTSTR
pszPrinterName=0) - if you want to print without Printer
select dialog box set pszPrinterName pointer to a
string which contains desired printer's name. You can the name of last used
printer with bvGetLastUsedPrinterName
function. pszFileName
is the name of a file where the output will be sent to by the printer's driver,
rarely used
-
void DoSetDocumentName(LPCTSTR pszDocName)
- this function sets the document, i.e. the name which will be seen in the
print spooler window while the document is being printed
-
void DoEnableMessageForwarding(BOOL bEnableMessageForwarding=FALSE)
- this function is used when you want to receive notifications about ALL
messages which comes to the preview window. Because of it is a very time
consuming by default the forwarding is off. If bEnableMessageForwarding
is TRUE then CcwForwardMessage(...)
virtual function will be called on every message.
-
HWND DoCreatePreview(HWND hWndParent,LPCTSTR
lpWindowName=_T(""),DWORD dwExStyle=WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE,DWORD dwStyle=WS_OVERLAPPEDWINDOW |
WS_CLIPCHILDREN | WS_CLIPSIBLINGS,LONG x=CW_USEDEFAULT ,LONG
y=CW_USEDEFAULT ,LONG nWidth=CW_USEDEFAULT ,LONG
nHeight=CW_USEDEFAULT ,HINSTANCE hInstance=0,LPVOID
lpParam=0) - this function creates frame preview window
-
void DoSetNumPages(LONG lPages) -
function sets the number of pages of the content
-
void DoSetInitialPreviewMode(COREPREVIEW_MODE PreviewMode,
float fZoom=1.0) - function sets the initiatial preview mode
of the preview window. The function fills the members lInitialPreviewMode
and fScaleFactor of COREPREVIEW_CALLBACK
structure. If you use it you must call the function before
creation of the preview window.
-
void DoInitCorePreview(PCOREPREVIEW_CALLBACK pCorePreviewCallback
) - the function initializes print preview window. COREPREVIEW_CALLBACK
structure must be filled in before this call
-
void DoSetPreviewMode (COREPREVIEW_MODE mode,
float fZoom =1.0) - sets the preview mode (see
COREPREVIEW_MODE
enumeration)
-
void DoShowMargins
(BOOL bShowMargins) - sets whether margins are shown
-
BOOL DoAreMarginsShown() - returns a boolean flag. The flag is
TRUE
when margins are shown
-
HWND DoGetSafeHwnd() - returns the value of m_hPreviewWindow
member variable
-
void DoPageDirty(unsigned Page) - send to the
preview window a message to inform it that the content of the page Page
has changed and the page needs to be redrawn
-
void DoSetNumPagesPerWidth(LONG Pages) -
sets the number of pages per preview window's width
-
LONG DoGetNumPagesPerWidth() - returns the number of pages
per preview window's width
-
void DoSetNumPagesPerHeight(LONG Pages) -
sets the number of pages per preview window's height
-
LONG DoGetNumPagesPerHeight() - returns the number of
pages per preview window's height
-
HWND DoGetCorePreviewWindowHandle() - returns the handle
of preview window, either when frame preview window or bare preview is used
-
void DoGetPreviewMode(COREPREVIEW_MODE & mode,float
& fZoom) - returns current preview mode of the preview window
-
void DoSetHdcCoordinateSpace(PCOREPREVIEW_COORDINATESPACE pCorePreviewCoordinateSpace)
- this function is for internal use only
-
void DoAttach(PCOREPREVIEW_CALLBACK pCorePreviewCallback)
- attaches the pCorePreviewCallback pointer to the instance of
the class.The pointer is stored in the m_pCorePreviewCallback
member variable
-
void DoDetach() - sets the m_pCorePreviewCallback
member variable to zero
The Di set is similar to Do set except the
fact that the Di set has one additional parameter, the handle
of the preview window hwnd. Because of it there is only
declarations, for details see the corresponding Do function
above.
-
void DiInitCorePreview(HWND hwnd
, PCOREPREVIEW_CALLBACK p)
-
void DiSetPreviewMode(HWND hwnd,
COREPREVIEW_MODE mode,float fZoom
=1.0)
-
void DiShowMargins(HWND hwnd
, BOOL b)
-
BOOL DiAreMarginsShown(HWND hwnd
)
-
void DiPageDirty(HWND hwnd
, unsigned Page)
-
void DiSetNumPagesPerWidth(HWND hwnd, LONG
Pages
)
-
LONG DiGetNumPagesPerWidth(HWND hwnd
)
-
void DiSetNumPagesPerHeight(HWND hwnd, LONG
Pages
)
-
LONG DiGetNumPagesPerHeight(HWND hwnd
)
-
HWND DiGetCorePreviewWindowHandle(HWND hwnd
)
-
void DiGetPreviewMode(HWND hwnd,COREPREVIEW_MODE
& mode, float & fZoom
)
-
void DiSetHdcCoordinateSpace(HWND hwnd,PCOREPREVIEW_COORDINATESPACE
pCorePreviewCoordinateSpace)