Skip to content

How to use FileSavePicker with C++/WinRT for desktop app? #1434

Answered by andrewleader
ZhouJJJKKK asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ZhouJJJKKK, sorry for the delayed response. In desktop-based apps, you have to use InitializeWithWindow on pickers like FilePicker to let the picker know which window (hwnd) it should display over.

    auto picker = winrt::Windows::Storage::Pickers::FileOpenPicker();
    picker.as<IInitializeWithWindow>()->Initialize(hwnd);
    ...

Here's some more info: https://docs.microsoft.com/windows/apps/desktop/modernize/desktop-to-uwp-supported-api#classes-that-use-iinitializewithwindow

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@nickrandolph
Comment options

@andrewleader
Comment options

@ZhouJJJKKK
Comment options

@benschop-it
Comment options

Answer selected by andrewleader
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants