Tips and Tricks
ATTENTION!
The library has been superseded by our new product, BestView library.
BestView offers a lot of new features, such as multilanguage
support, new exact coordinate system, dynamic pages and so on.
Find a minute and visit BestView home page.
1. Short introduction
There are three
stages that users have to pass.
1.1. Initialization
This is the first step. During an application initialization the user calls
function pvlRegisterClasses (or
pvlRegisterClasses2 ) and pass there
HINSTANCE
of the application. Library initializes its internal structures. If the
call of this function succeeded then everything is OK.
1.2. Working with library
Here the user is working with the library.
1.3. Completion
At the end of work the application has to call the pvlUnregisterClasses
function to clean up all internal resources that have been allocated
by the library.
2. Useful notes
All work with the library passes on the stage two. Here are some important
particular qualities:
-
The first is the call order of the callback functions. The order is
following:
-
fnPrepareDC
- the function is called when a preview window is creating or user
changes printer or its properties.
-
fnInit - the function is called immediately after
fnPrepareDC.
The user has to build the content of all pages during this call.
-
fnGetNumPages -the function is called to get
the number of pages in the content.
-
fnDrawPage - the function is called every
time when the page needs to be drawn.
-
fnCanBeClosed - the function is called when
user tries to close the preview window.
-
fnWindowCutOff - the function is called once when
the preview window is closing, to perform cleanup.
-
Second is working with
PVL_CALLBACK
structure. To help to work with this structure there is a helper C++ class,
PVL_CALLBACK_WRAPPER, declared in pvl.h.
To work with this class the users have to inherit their own class
from this one and implement the functions below(see examples):
-
virtual HRESULT
PrepareDC(HWND,DEVMODEA
*,LONG);
-
virtual HRESULT
Init(HWND,HDC,const
DEVMODEA *);
-
virtual HRESULT
GetNumPages(HWND,const
DEVMODEA *,LONG*);
-
virtual HRESULT
DrawPage(HWND,HDC,DWORD,DWORD);
-
virtual HRESULT
CanBeClosed(HWND,LONG*);
-
virtual HRESULT
WindowCutOff(HWND);
-
virtual HRESULT
PrintDisabled(HWND);
-
The control has an absolute coordinate system. It utilizes pixels as units; So,
when
fnInit
is called, that is a good place to get all metrics of the device context that
has been creating, save them and use the ones during the all life cycle of the
preview window.