Hide

SftPrintPreview/DLL 2.0 - Print Preview Control for C/C++

Display
Print

Using C++/MFC

This section describes how to use SftPrintPreview/DLL in an application written using C++ and the Microsoft Foundation Class library (MFC).

Building an Application

Please see "Building Applications" to prepare a project for development with SftPrintPreview/DLL.

A)Every source program making use of a SftPrintPreview/DLL control must include the required header file SftPrintPreview.h by using the #include directive.
#include "SftPrintPreview.h" /* SftPrintPreview/DLL required header file */

This include statement should appear after the #include <stdafx.h> statement or can be included at the end of stdafx.h. The file is located in the directory \Program Files\Softelvdm\SftPrintPreview DLL 2.0\Include (unless changed during the installation).The project settings may need to be updated so the #include file can be located.

B)The source program SftPrintPreviewMFC.CPP must be added to your project. It is added to the project, without making any modifications to the file, using Visual C++'s Project, Add To Project, Files... menu command. The file is located in the directory \Program Files\Softelvdm\SftPrintPreview DLL 2.0\Include (unless changed during the installation).Instead of simply adding it to the project, you can include the file using the #include directive. However, it must be included in a source file (*.CPP) as it is not a header file and only one source file can #include the file SftPrintPreviewMFC.CPP.
#include "SftPrintPreviewMFC.cpp"

This include statement should appear after the #include "SftPrintPreview.h" statement.The project settings may need to be updated so the source file of #include file can be located.

C)In order to use SftPrintPreview/DLL controls, an application must call the CSftPrintPreview::RegisterApp function. The call to this function is required so that SftPrintPreview/DLL window classes can be registered. This call has to be made before any SftPrintPreview/DLL controls are created. Add the following statement to your source code. The preferred location is the InitInstance member function of your CWinApp or CSftPrintPreview_App based application object:
CSftPrintPreview::RegisterApp(); /* Use SftPrintPreview/DLL with this application */
D)Once SftPrintPreview/DLL controls are no longer needed, an application must call the CSftPrintPreview::UnregisterApp function. The call to this function is required so that SftPrintPreview/DLL window classes can be unregistered and cleanup processing can take place. This call has to be made after all SftPrintPreview/DLL controls have been destroyed. The preferred location is the ExitInstance member function of your CWinApp based application object:
CSftPrintPreview::UnregisterApp(); /* No longer use SftPrintPreview/DLL */
E)The application's executable (Exe or Dll) must be linked with the correct Lib file, depending on the target environment. Please see "Building Applications" for more information.The project settings may need to be updated so the Lib files can be located (see "Building Applications" for more information).

Adding a Print Preview Control

ClassWizard does not support new classes such as CSftPrintPreview, so any Print Preview control instance variables, notification handlers, message map entries, etc., have to be added manually.

There are two methods to add a Print Preview control to an application:

Adding a Print Preview control using dialog resources is accomplished by using a resource editor to design a dialog. For more information, see Creating a Dialog Resource with Visual C++. Once a Print Preview control is created, its CSftPrintPreview based object can be obtained by using the Windows GetDlgItem function or attached to a CSftPrintPreview object using SubclassDlgItem.

CSftPrintPreview * pPreviewControl;
pPreviewControl = (CSftPrintPreview *) GetDlgItem(IDC_PREVIEW);

or

CSftPrintPreview m_Preview;
m_Preview.SubclassDlgItem(IDC_PREVIEW, this);

Another method to create a Print Preview control is by using the CSftPrintPreview::Create member function.

CSftPrintPreview m_Preview;
m_Preview.Create(WS_CHILD | WS_VISIBLE, CRect(250,200,400,700), pParentWnd, IDC_PREVIEW);

For more information on the various parameters used, see the Create member function documentation.


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.