Hide

SftPrintPreview/OCX 1.0 - ActiveX Print Preview Control

Display
Print

SftPrintPreview.RenderContent Event

Page drawing event.

Syntax

VB.NETPrivate Sub object_RenderContent(ByVal sender As Object, ByVal e As EventArgumentType) Handles object.RenderContent
VBPrivate Sub object_RenderContent(ByVal Function As SftPrintPreviewRenderContentConstants, LastPage As Long, VisitedPageInfo As Variant)
C#.NETvoid object_RenderContent(object sender, EventArgumentType e);
VC++void OnRenderContentobject(enum SftPrintPreviewRenderContentConstants Function, long* LastPage, const _variant_t&* VisitedPageInfo);
CHRESULT OnRenderContentobject(enum SftPrintPreviewRenderContentConstants Function, long* LastPage, VARIANT* VisitedPageInfo);

object

A SftPrintPreview object.

Function

Describes the function to be performed by the event handler.

NameValueDescription
renderSftPrintPreview_Init1Initialize - Called each time the preview display is repainted or pages are printed, to initialize print/preview of one or more pages. This call is typically used to initialize and allocate resources that are used to render pages.
renderSftPrintPreview_1Page2One Page - Called to render one page into the output device context RenderingInfo.hDC.
renderSftPrintPreview_Term3Terminate - Called each time the preview display has completed repainting or pages have been printed, to terminate print/preview of one or more pages. This call is typically used to free resources that were allocated during the preceding renderSftPrintPreview_Init call.
renderSftPrintPreview_ClearCache4Clear Cache - Called when the entire output needs to be reformatted, because the page and printer attributes have changed, causing all pages to require reformatting. This call is used to free any information saved by the callback routine aiding in page positioning.
renderSftPrintPreview_Dimensions5Dimensions - Called before rendering one page (renderSftPrintPreview_1Page) to determine the desired dimensions of the output. This call is used to allow the callback to decide how the output is placed on the output page (see ContentSizing property).

LastPage

The RenderContent event handler code returns the page number of the last page, once it is known. Otherwise, this value should not be modified. Until a last page is known, new pages will be formatted and displayed as needed. Page numbers are zero-based.

VisitedPageInfo

The RenderContent event handler code returns an application defined value describing the exact output position to resume printing of the next page.

Comments

The RenderContent event occurs informing the application of a page drawing request.

This method is not supported for use with Visual Basic 6.0

When the RenderContent event is called with a Function argument of renderSftPrintPreview_1Page, the application renders the requested page RenderingInfo.CurrentPage. At the end, it can save an application defined value in the VisitedPageInfo argument of the event. This value can be a simple long value, or even an object or a pointer to an application allocated structure. In either case, the value describes the exact output position necessary to resume printing (the next page). SftPrintPreview/OCX saves all these returned values and they are accessible through the VisitedPageInfo property. The VisitedPageInfo property is an array of application-defined values, one entry for each visited page (starting at the first page, page 0). Up to VisitedPages entries are available.

Examples

VB.NET

Private Sub AxSftPrintPreview1_HelpWanted(ByVal sender As Object, ByVal e As AxSftPrintPreviewLib10._ISftPrintPreviewEvents_HelpWantedEvent) Handles AxSftPrintPreview1.HelpWanted
    MessageBox.Show("Sorry, this sample doesn't offer a help file")
End Sub

Private Sub AxSftPrintPreview1_CloseWanted(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftPrintPreview1.CloseWanted
    Application.Exit()
End Sub

Private Sub AxSftPrintPreview1_RenderContent(ByVal sender As Object, ByVal e As AxSftPrintPreviewLib10._ISftPrintPreviewEvents_RenderContentEvent) Handles AxSftPrintPreview1.RenderContent
    ' This function is called by SftPrintPreview to print pages, to initialize and
    ' terminate printing (to prepare and free resources) and for page positioning
    If e.function = SftPrintPreviewRenderContentConstants.renderSftPrintPreview_Init Then
        m_PrintFont = New Font("Arial", 10)
    ElseIf e.function = SftPrintPreviewRenderContentConstants.renderSftPrintPreview_Term Then
        m_PrintFont = Nothing
    ElseIf e.function = SftPrintPreviewRenderContentConstants.renderSftPrintPreview_1Page Then

C#

    MessageBox.Show("Sorry, this sample doesn't offer a help file");
}

private void axSftPrintPreview1_PageSetupWanted(object sender, System.EventArgs e)
{
    axSftPrintPreview1.PageSetup(0);
}

private void axSftPrintPreview1_RenderContent(object sender, AxSftPrintPreviewLib10._ISftPrintPreviewEvents_RenderContentEvent e)
{
    // This function is called by SftPrintPreview to print pages, to initialize and
    // terminate printing (to prepare and free resources) and for page positioning
    if (e.function == SftPrintPreviewRenderContentConstants.renderSftPrintPreview_Init)
        m_PrintFont = new Font("Arial", 10);
    else if (e.function == SftPrintPreviewRenderContentConstants.renderSftPrintPreview_Term)
        m_PrintFont = null;

C++

    OnOK();
}

void CSftPrintPreviewDlg::OnHelpWantedSftPrintPreview1(LPCTSTR HelpName)
{
    MessageBox(_T("Sorry, this sample doesn't offer a help file"));
}

void CSftPrintPreviewDlg::OnRenderContentSftPrintPreview1(long Function, long FAR* LastPage, VARIANT FAR* VisitedPageInfo)
{
    // This function is called by SftPrintPreview to print pages, to initialize and
    // terminate printing (to prepare and free resources) and for page positioning
    if (Function == renderSftPrintPreview_Init) {
        SftPrintPreviewRenderingInfo I = m_vPrintPreview1->GetRenderingInfo();
        int height = MulDiv(10, GetDeviceCaps((HDC)I.hDCPrinter, LOGPIXELSY), 72);// 10 point font
        m_PrintFont.CreateFont(- height, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,

See Also SftPrintPreview Object | Object Hierarchy


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