Skip to content

How can I offer the same screen capture options? #5559

Description

@ajtruckle

The sample application has an option to save a screen capture and uses this code:

void FileComponent::SaveScreenshot()
{
    WCHAR defaultName[MAX_PATH] = L"WebView2_Screenshot.png";
    OPENFILENAME openFileName = CreateOpenFileName(defaultName, L"PNG File\0*.png\0");
    if (GetSaveFileName(&openFileName))
    {
        wil::com_ptr<IStream> stream;
        CHECK_FAILURE(SHCreateStreamOnFileEx(
            defaultName, STGM_READWRITE | STGM_CREATE, FILE_ATTRIBUTE_NORMAL, TRUE, nullptr,
            &stream));

        CHECK_FAILURE(m_webView->CapturePreview(
            COREWEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT_PNG, stream.get(),
            Callback<ICoreWebView2CapturePreviewCompletedHandler>(
                [appWindow{m_appWindow}](HRESULT error_code) -> HRESULT {
                    CHECK_FAILURE(error_code);
                    appWindow->AsyncMessageBox(L"Preview Captured", L"Preview Captured");
                    return S_OK;
                })
                .Get()));
    }
}
//! [CapturePreview]

But in Microsoft Edge itself, when using Screenshot, it offers us useful options:

Image

How can I offer the same options?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions