SimpleWindow
载入中...
搜索中...
未找到
FolderDialog.h
1#pragma once
2
3#include "EnumBit.h"
4#include "Window.h"
5#include <Shlobj.h>
6
7namespace sw
8{
12 enum class FolderDialogFlags : UINT {
13 // Only return file system directories. If the user selects folders that are not part of the
14 // file system, the OK button is grayed.
15 // Note The OK button remains enabled for "\\server" items, as well as "\\server\share" and
16 // directory items. However, if the user selects a "\\server" item, passing the PIDL returned
17 // by SHBrowseForFolder to SHGetPathFromIDList fails.
18 ReturnOnlyFileSystemDirs = 0x00000001,
19
20 // Do not include network folders below the domain level in the dialog box's tree view control.
21 DontGoBelowDomain = 0x00000002,
22
23 // Include a status area in the dialog box. The callback function can set the status text by
24 // sending messages to the dialog box. This flag is not supported when BIF_NEWDIALOGSTYLE is
25 // specified.
26 StatusText = 0x00000004,
27
28 // Only return file system ancestors. An ancestor is a subfolder that is beneath the root folder
29 // in the namespace hierarchy. If the user selects an ancestor of the root folder that is not
30 // part of the file system, the OK button is grayed.
31 ReturnFileSystemAncestors = 0x00000008,
32
33 // Version 4.71. Include an edit control in the browse dialog box that allows the user to type
34 // the name of an item.
35 EditBox = 0x00000010,
36
37 // Version 4.71. If the user types an invalid name into the edit box, the browse dialog box calls
38 // the application's BrowseCallbackProc with the BFFM_VALIDATEFAILED message. This flag is ignored
39 // if BIF_EDITBOX is not specified.
40 Validate = 0x00000020,
41
42 // Version 5.0. Use the new user interface. Setting this flag provides the user with a larger
43 // dialog box that can be resized. The dialog box has several new capabilities, including:
44 // drag-and-drop capability within the dialog box, reordering, shortcut menus, new folders,
45 // delete, and other shortcut menu commands.
46 // Note If COM is initialized through CoInitializeEx with the COINIT_MULTITHREADED flag set,
47 // SHBrowseForFolder fails if BIF_NEWDIALOGSTYLE is passed.
48 NewDialogStyle = 0x00000040,
49
50 // Version 5.0. The browse dialog box can display URLs. The BIF_USENEWUI and BIF_BROWSEINCLUDEFILES
51 // flags must also be set. If any of these three flags are not set, the browser dialog box rejects
52 // URLs. Even when these flags are set, the browse dialog box displays URLs only if the folder that
53 // contains the selected item supports URLs. When the folder's IShellFolder::GetAttributesOf method
54 // is called to request the selected item's attributes, the folder must set the SFGAO_FOLDER attribute
55 // flag. Otherwise, the browse dialog box will not display the URL.
56 BrowseIncludeUrls = 0x00000080,
57
58 // Version 5.0. Use the new user interface, including an edit box. This flag is equivalent to
59 // BIF_EDITBOX | BIF_NEWDIALOGSTYLE.
60 // Note If COM is initialized through CoInitializeEx with the COINIT_MULTITHREADED flag set,
61 // SHBrowseForFolder fails if BIF_USENEWUI is passed.
62 UseNewUI = 0x00000010 | 0x00000040,
63
64 // Version 6.0. When combined with BIF_NEWDIALOGSTYLE, adds a usage hint to the dialog box, in place
65 // of the edit box. BIF_EDITBOX overrides this flag.
66 UsageHint = 0x00000100,
67
68 // Version 6.0. Do not include the New Folder button in the browse dialog box.
69 NoNewFolderButton = 0x00000200,
70
71 // Version 6.0. When the selected item is a shortcut, return the PIDL of the shortcut itself rather
72 // than its target.
73 NoTranslateTargets = 0x00000400,
74
75 // Only return computers. If the user selects anything other than a computer, the OK button is grayed.
76 BrowseForComputer = 0x00001000,
77
78 // Only allow the selection of printers. If the user selects anything other than a printer, the OK
79 // button is grayed.
80 // In Windows XP and later systems, the best practice is to use a Windows XP-style dialog, setting
81 // the root of the dialog to the Printers and Faxes folder (CSIDL_PRINTERS).
82 BrowseForPrinter = 0x00002000,
83
84 // Version 4.71. The browse dialog box displays files as well as folders.
85 BrowseIncludeFiles = 0x00004000,
86
87 // Version 5.0. The browse dialog box can display sharable resources on remote systems. This is intended
88 // for applications that want to expose remote shares on a local system. The BIF_NEWDIALOGSTYLE flag must
89 // also be set.
90 Sharable = 0x00008000,
91
92 // Windows 7 and later. Allow folder junctions such as a library or a compressed file with a .zip file
93 // name extension to be browsed.
94 BrowseFileJunctions = 0x00010000,
95 };
96
100 _SW_ENUM_ENABLE_BIT_OPERATIONS(FolderDialogFlags);
101
106 {
107 private:
111 BROWSEINFOW _bi{};
112
116 std::vector<wchar_t> _buffer;
117
121 std::wstring _description;
122
123 public:
128
133
138
143
148
149 public:
154
158 virtual void Close() override;
159
163 virtual void Show() override;
164
169 virtual int ShowDialog(Window *owner = nullptr) override;
170
175 virtual int ShowDialog(Window &owner);
176
177 protected:
181 BROWSEINFOW *GetBI();
182
186 wchar_t *GetBuffer();
187
192 };
193}
选择文件夹对话框
Definition FolderDialog.h:106
virtual int ShowDialog(Window *owner=nullptr) override
显示对话框,并指定所有者窗口
const Property< bool > NewFolderButton
是否显示“新建文件夹”按钮
Definition FolderDialog.h:147
const ReadOnlyProperty< std::wstring > SelectedPath
选中文件夹的路径
Definition FolderDialog.h:142
virtual int ShowDialog(Window &owner)
显示对话框,并指定所有者窗口
const Property< FolderDialogFlags > Flags
对话框标志
Definition FolderDialog.h:132
const Property< std::wstring > Description
对话框上方显示的描述性文本
Definition FolderDialog.h:137
virtual void Close() override
FolderBrowserDialog默认不支持该函数,调用该函数不会执行任何操作
BROWSEINFOW * GetBI()
获取BROWSEINFOW指针
wchar_t * GetBuffer()
获取指向缓冲区的指针
virtual void Show() override
FolderBrowserDialog默认不支持该函数,调用该函数不会执行任何操作
void ClearBuffer()
清空缓冲区
FolderBrowserDialog()
初始化FolderBrowserDialog
const Property< int > BufferSize
储存文件名的缓冲区大小,值不能小于MAX_PATH
Definition FolderDialog.h:127
对话框接口
Definition IDialog.h:11
属性
Definition Property.h:1743
只读属性
Definition Property.h:1828
窗口
Definition Window.h:35