HRESULT STDMETHODCALLTYPE WebKitUIDelegate::webViewPrintingMarginRect(
    /* [in] */ IWebView *webView,
    /* [retval][out] */ RECT *rect)
{

    if (!webView || !rect)
        return E_POINTER;

    IWebFrame* mainFrame = 0;
    if (FAILED(webView->mainFrame(&mainFrame)))
        return E_FAIL;

    IWebFramePrivate* framePrivate = 0;
    if (FAILED(mainFrame->QueryInterface(&framePrivate))) {
        mainFrame->Release();
        return E_FAIL;
    }

    framePrivate->frameBounds(rect);
    rect->left += MARGIN;
    rect->top += MARGIN;
    rect->right -= MARGIN;
    rect->bottom -= MARGIN;

    framePrivate->Release();
    mainFrame->Release();

    return S_OK;
}
Exemple #2
0
HRESULT PrintWebUIDelegate::webViewPrintingMarginRect(IWebView* view, RECT* rect)
{
    if (!view || !rect)
        return E_POINTER;

    IWebFrame* mainFrame = 0;
    if (FAILED(view->mainFrame(&mainFrame)))
        return E_FAIL;

    IWebFramePrivate* privateFrame = 0;
    if (FAILED(mainFrame->QueryInterface(&privateFrame))) {
        mainFrame->Release();
        return E_FAIL;
    }

    privateFrame->frameBounds(rect);

    rect->left += MARGIN;
    rect->top += MARGIN;
    HDC dc = ::GetDC(0);
    rect->right = (::GetDeviceCaps(dc, LOGPIXELSX) * 6.5) - MARGIN;
    rect->bottom = (::GetDeviceCaps(dc, LOGPIXELSY) * 11) - MARGIN;
    ::ReleaseDC(0, dc);

    privateFrame->Release();
    mainFrame->Release();

    return S_OK;
}