Hide

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

Display
Print

SftPrintPreview_RenderRicheditWindow_Callback Function

The SftPrintPreview_RenderRicheditWindow_Callback function implements a callback used to print/preview RichEdit controls.

C

BOOL CALLBACK SftPrintPreview_RenderRicheditWindow_Callback(
    LPSFTPRINTPREVIEW_DRAWINFO lpInfo);

Parameters

lpInfo

A pointer to a SFTPRINTPREVIEW_DRAWINFO structure defining the current rendering operation.

Returns

The return value is TRUE if the function was successful, FALSE otherwise.

Comments

The SftPrintPreview_RenderRicheditWindow_Callback function implements a callback used to print/preview RichEdit controls.

It is used with the FilePrintPreview function (C++) or as the lpDrawInfoProc member of the SFTPRINTPREVIEW_CONTROL structure (C) when printing/previewing RichEdit controls.

Example

Actual Implementation of the SftPrintPreview_RenderRicheditWindow_Callback for RichEdit controls, built into SftPrintPreview/DLL.

C

BOOL CALLBACK SftPrintPreview_RenderRicheditWindow_Callback(
    LPSFTPRINTPREVIEW_DRAWINFO lpInfo)
{
     ASSERT(lpInfo->hwndContent);
     if (!lpInfo->hwndContent) return FALSE;

     switch (lpInfo->function) {
         case SFTPRINTPREVIEW_PRINT_CLEARCACHE:
             AU(SendMessage)(lpInfo->hwndContent, EM_FORMATRANGE, 0, (LPARAM)NULL);
             return TRUE;
         case SFTPRINTPREVIEW_PRINT_DIMENSIONS:
             lpInfo->contentWidth = -1;
             return TRUE;
         case SFTPRINTPREVIEW_PRINT_ONEPAGE:
             break;// continue below;
         default:
             return TRUE;
     }

    //SFTPRINTPREVIEW_PRINT_ONEPAGE

    FORMATRANGE fr;
    memset(&fr, 0, sizeof(fr));

    fr.hdc = lpInfo->hDC;
    fr.hdcTarget = lpInfo->hDCPrinter;

    fr.rc.left = (int) (((float)lpInfo->ClientRect.left)/GetDeviceCaps(lpInfo->hDC, LOGPIXELSX)*1440);
    fr.rc.top = (int) (((float)lpInfo->ClientRect.top)/GetDeviceCaps(lpInfo->hDC, LOGPIXELSX)*1440);
    fr.rc.right = fr.rc.left + (int) (((float)(lpInfo->ClientRect.right-lpInfo->ClientRect.left))/GetDeviceCaps(lpInfo->hDC, LOGPIXELSX)*1440);
    fr.rc.bottom = fr.rc.top + (int) (((float)(lpInfo->ClientRect.bottom-lpInfo->ClientRect.top))/GetDeviceCaps(lpInfo->hDC, LOGPIXELSY)*1440);

    fr.rcPage = fr.rc;

    fr.chrg.cpMin = (int) (lpInfo->absPage > 0) ? lpInfo->previousVisitedPageInfo : 0;
    fr.chrg.cpMax = -1;

    long nextProcessChar = 0;
    nextProcessChar = AU(SendMessage)(lpInfo->hwndContent, EM_FORMATRANGE, TRUE, (LPARAM)&fr);
    GETTEXTLENGTHEX gtl;
    gtl.flags = GTL_DEFAULT;
#if defined(UNICODE)
    gtl.codepage = 1200;
#else
    gtl.codepage = CP_ACP;
#endif
    int len = AU(SendMessage)(lpInfo->hwndContent, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
    if (nextProcessChar >= len)
        lpInfo->lastPage = lpInfo->absPage;

    lpInfo->visitedPageInfo = nextProcessChar;

    return TRUE;
}

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


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