SftPrintPreview/DLL 2.0

SFTPRINTPREVIEW_CUSTOMVAR

Softel vdm, Inc.

The SFTPRINTPREVIEW_CUSTOMVAR structure is used to describe a variable name used for string substitution in headers and footers.

typedef struct tagSftPrintPreviewCustomVar {
    LPCTSTR lpszVarName;                     // variable name (without lead-in)
    LPCTSTR lpszText;                        // new text to be substituted
} SFTPRINTPREVIEW_CUSTOMVAR, * LPSFTPRINTPREVIEW_CUSTOMVAR;
typedef const SFTPRINTPREVIEW_CUSTOMVAR * LPCSFTPRINTPREVIEW_CUSTOMVAR;

Members

lpszVarName

The variable name. Leading/trailing % characters must not be included.

lpszText

The text to be substituted for the variable.

Comments

The SFTPRINTPREVIEW_CUSTOMVAR structure is used to describe a variable name used for string substitution in headers and footers.

An application can provide a table of custom string substitution variables for the headers/footers. Each entry in the table consists of a SFTPRINTPREVIEW_CUSTOMVAR structure describing one variable.

The table is defined using SFTPRINTPREVIEW_CONTROL, lpCustomVars.

Example

C

static SFTPRINTPREVIEW_CUSTOMVAR customVariables[] = {
    { "MyVar1", "Text substituted for MyVar1", },
    { "MyVar2", "Text substituted for the other variable", },
    { NULL, NULL },
};

// retrieve current control settings
SFTPRINTPREVIEW_CONTROL Ctl;
Ctl.cbSize = sizeof(SFTPRINTPREVIEW_CONTROL);
if (!SftPrintPreview_GetControlInfo(hwndCtl, &Ctl)) {
    _ASSERT(0); // the SFTPRINTPREVIEW_CONTROL structure's cbSize member wasn't initialized properly
    return;
}

// set all desired options
Ctl.numPageRows = 1;                // default to 1x2 pages
Ctl.numPageGroups = 2;
Ctl.zoom = 0;                       // start out with multiple pages
lstrcpy(Ctl.szOutputName, TEXT("Sample Output")); // job name when printing
lstrcpy(Ctl.szHeaderRight, TEXT("Header %MyVar1% <-variable"));
lstrcpy(Ctl.szFooterLeft, TEXT("Here we use %MyVar2%"));

Ctl.lpCustomVars = customVariables;

Ctl.fCenterOnClick = FALSE;
Ctl.fDragPage  = TRUE;
Ctl.iZoomStyle = SFTPRINTPREVIEW_ZOOMSTYLE_BOTHBUTTONS_EXACT;

if (!SftPrintPreview_SetControlInfo(hwndCtl, &Ctl)) {
    int errorValue = Ctl.errorValue;
    _ASSERT(0); // an error occurred, check errorValue for error code
    return;
}

C++

void CPreviewPagePrinting::CustomizeControl(LPSFTPRINTPREVIEW_CONTROL lpCtl)
{
    static SFTPRINTPREVIEW_CUSTOMVAR customVariables[] = {
        { "MyVar1", "Text substituted for MyVar1", },
        { "MyVar2", "Text substituted for the other variable", },
        { NULL, NULL },
    };

    lpCtl->numPageRows = 1;                // default to 1x2 pages
    lpCtl->numPageGroups = 2;
    lpCtl->zoom = 0;                       // start out with multiple pages

    lpCtl->fCenterOnClick = FALSE;
    lpCtl->fDragPage  = TRUE;
    lpCtl->iZoomStyle = SFTPRINTPREVIEW_ZOOMSTYLE_BOTHBUTTONS_EXACT;

    lstrcpy(lpCtl->szHeaderRight, TEXT("Header %MyVar1% <-variable"));
    lstrcpy(lpCtl->szFooterLeft, TEXT("Here we use %MyVar2%"));

    lpCtl->lpCustomVars = customVariables;
}

See Also  C/C++ API  |  C++ Classes  |  Notifications


Feedback / comments / error reports for this topic
© 2016 - Softel vdm, Inc. - www.softelvdm.com