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:
How can I offer the same options?
The sample application has an option to save a screen capture and uses this code:
But in Microsoft Edge itself, when using Screenshot, it offers us useful options:
How can I offer the same options?