1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/private/filedialog.h
// Purpose: IFileDialog-related functions
// Author: Vadim Zeitlin
// Created: 2022-05-15
// Copyright: (c) 2022 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_PRIVATE_FILEDIALOG_H_
#define _WX_MSW_PRIVATE_FILEDIALOG_H_
#include "wx/msw/private.h"
#include "wx/msw/wrapshl.h"
// We want to use IFileDialog if either wxDirDialog or wxFileDialog are used.
//
// IFileOpenDialog implementation needs wxDynamicLibrary for
// run-time linking SHCreateItemFromParsingName(), available
// only under Windows Vista and newer.
// It also needs a compiler providing declarations and definitions
// of interfaces available in Windows Vista.
// And it needs OLE support to actually use these interfaces.
#if (wxUSE_DIRDLG || wxUSE_FILEDLG) && wxUSE_DYNLIB_CLASS && wxUSE_OLE && \
defined(__IFileOpenDialog_INTERFACE_DEFINED__)
#define wxUSE_IFILEOPENDIALOG 1
#else
#define wxUSE_IFILEOPENDIALOG 0
#endif
#if wxUSE_IFILEOPENDIALOG
#include "wx/msw/private/comptr.h"
namespace wxMSWImpl
{
// For historical reasons, this class is defined in src/msw/dirdlg.cpp.
class wxIFileDialog
{
public:
// Create the dialog of the specified type.
//
// CLSID must be either CLSID_FileOpenDialog or CLSID_FileSaveDialog.
//
// Use IsOk() to check if the dialog was created successfully.
explicit wxIFileDialog(const CLSID& clsid);
// If this returns false, the dialog can't be used at all.
bool IsOk() const { return m_fileDialog.Get() != NULL; }
// Set the dialog title.
void SetTitle(const wxString& title);
// Set the initial path to show in the dialog.
void SetInitialPath(const wxString& path);
// Add a shortcut.
void AddPlace(const wxString& path, FDAP fdap);
// Show the file dialog with the given parent window and options.
//
// Returns the selected path, or paths, in the provided output parameters,
// depending on whether FOS_ALLOWMULTISELECT is part of the options.
//
// The return value is wxID_OK if any paths were returned, wxID_CANCEL if the
// dialog was cancelled.
int
Show(HWND owner, int options, wxArrayString* pathsOut, wxString* pathOut);
// Behave as IFileDialog.
IFileDialog* Get() const { return m_fileDialog.Get(); }
IFileDialog* operator->() const { return m_fileDialog.Get(); }
private:
wxCOMPtr<IFileDialog> m_fileDialog;
};
// Initialize an IShellItem object with the given path.
HRESULT InitShellItemFromPath(wxCOMPtr<IShellItem>& item, const wxString& path);
// Extract the filesystem path corresponding to the given shell item.
HRESULT GetFSPathFromShellItem(const wxCOMPtr<IShellItem>& item, wxString& path);
} // namespace wxMSWImpl
#endif // wxUSE_IFILEOPENDIALOG
#endif // _WX_MSW_PRIVATE_FILEDIALOG_H_
|