Hide

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

Display
Print

Using C

This section describes how to use SftPrintPreview/DLL in an application written using the C programming language.

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 <windows.h> statement. 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)In order to use SftPrintPreview/DLL controls, an application must call the SftPrintPreview_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, where your application registers its window classes (normally during application initialization):
SftPrintPreview_RegisterApp(hInstance); /* Use SftPrintPreview/DLL with this application */
C)Once SftPrintPreview/DLL controls are no longer needed, an application must call the SftPrintPreview_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 (normally during application termination).
SftPrintPreview_UnregisterApp(hInstance); /* No longer use SftPrintPreview/DLL */
D)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

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

  • using dialog resources
  • using CreateWindow(Ex)

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

Another method to create a Print Preview control is by using the CreateWindow(Ex) Windows call:

hwndPreview = CreateWindow(TEXT(SFTPRINTPREVIEW_CLASS), NULL,
     WS_CHILD, 0, 0, 0, 0, hwndMain,
     (HMENU) IDC_PREVIEW, hInstance, NULL);

For more information on the various parameters used, see the Windows API documentation.


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