Hide

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

Display
Print

Print Function

The Print function prints the contents.

C

BOOL SftPrintPreview_Print(HWND hwnd, HWND hwndMainWindow);

C++

BOOL CSftPrintPreview::Print(HWND hwndMainWindow = NULL);

Parameters

hwnd

The window handle of the Print Preview control.

hwndMainWindow

The window handle of the application's main window, which serves as the parent window for the print progress dialog. If NULL is specified, the application's main window is determined automatically.

Returns

The return value is TRUE if the function was successful, FALSE otherwise. If the user cancels printing, FALSE is returned.

Comments

The Print function prints the contents.

The range of pages to be printed is defined using the SFTPRINTPREVIEW_CONTROL structure member iPrintPages. If the Print dialog (see Print Dialog function) precedes the Print function, the page range entered by the user was automatically saved in the SFTPRINTPREVIEW_CONTROL structure and is used.

While printing is in progress, a modeless dialog is shown informing the user that printing is in progress, along with the current page count. This dialog allows the end-user to cancel printing. This dialog can be enabled or suppressed using the SFTPRINTPREVIEW_CONTROL structure (fWantCancelDialog).

If printing fails, the Print function automatically displays an error message with additional information. This message can be enabled or suppressed using the SFTPRINTPREVIEW_CONTROL structure (fShowErrorMessage).

If printing fails, additional error information is available by retrieving the SFTPRINTPREVIEW_CONTROL structure (fPrintUserAbort, fPrintAppShutDown, fPrintPageOutOfRange, dwdPrintLastError, szPrintLastFunc).

Example

C

LRESULT CALLBACK MainWindowProc(HWND hwndMain, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
        case WM_COMMAND: {
            HWND hwndCtl = (HWND) lParam;
            int id = LOWORD(wParam);
            int code = HIWORD(wParam);
            if (hwndCtl) {
                switch (id) {
                    case IDC_PREVIEW:
                        switch (code) {
                            case SFTPRINTPREVIEWN_STARTPRINTING:
                                SftPrintPreview_Print(hwndCtl, hwndMain);
                            break;
                        }
                        break;
                }
            }
            break;
        }
    }
    return DefWindowProc(hwndMain, uMsg, wParam, lParam);
}

C++

BEGIN_MESSAGE_MAP(CPreviewDialog, CDialog)
    ON_SFTPRINTPREVIEWN_STARTPRINTING(IDC_PREVIEW, OnStartPrinting)
END_MESSAGE_MAP()

afx_msg void CPreviewDialog::OnStartPrinting()
{
    SftPrintPreview_Print(m_Preview, m_hWnd);
}

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


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