]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/msw/wrapshl.h | |
3 | // Purpose: wrapper class for stuff from shell32.dll | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 2004-10-19 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2004 Vadim Zeitlin <vadim@wxwindows.org> | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_MSW_WRAPSHL_H_ | |
13 | #define _WX_MSW_WRAPSHL_H_ | |
14 | ||
15 | #include "wx/msw/wrapwin.h" | |
16 | ||
17 | #ifdef __WXWINCE__ | |
18 | #include <winreg.h> | |
19 | #include <objbase.h> | |
20 | #include <shlguid.h> | |
21 | #include <shellapi.h> | |
22 | #endif | |
23 | ||
24 | #include <shlobj.h> | |
25 | ||
26 | #include "wx/msw/winundef.h" | |
27 | ||
28 | // ---------------------------------------------------------------------------- | |
29 | // wxItemIdList implements RAII on top of ITEMIDLIST | |
30 | // ---------------------------------------------------------------------------- | |
31 | ||
32 | class wxItemIdList | |
33 | { | |
34 | public: | |
35 | // ctor takes ownership of the item and will free it | |
36 | wxItemIdList(LPITEMIDLIST pidl) | |
37 | { | |
38 | m_pidl = pidl; | |
39 | } | |
40 | ||
41 | static void Free(LPITEMIDLIST pidl) | |
42 | { | |
43 | if ( pidl ) | |
44 | { | |
45 | LPMALLOC pMalloc; | |
46 | SHGetMalloc(&pMalloc); | |
47 | if ( pMalloc ) | |
48 | { | |
49 | pMalloc->Free(pidl); | |
50 | pMalloc->Release(); | |
51 | } | |
52 | else | |
53 | { | |
54 | wxLogLastError(wxT("SHGetMalloc")); | |
55 | } | |
56 | } | |
57 | } | |
58 | ||
59 | ~wxItemIdList() | |
60 | { | |
61 | Free(m_pidl); | |
62 | } | |
63 | ||
64 | // implicit conversion to LPITEMIDLIST | |
65 | operator LPITEMIDLIST() const { return m_pidl; } | |
66 | ||
67 | // get the corresponding path, returns empty string on error | |
68 | wxString GetPath() const | |
69 | { | |
70 | wxString path; | |
71 | if ( !SHGetPathFromIDList(m_pidl, wxStringBuffer(path, MAX_PATH)) ) | |
72 | { | |
73 | wxLogLastError(_T("SHGetPathFromIDList")); | |
74 | } | |
75 | ||
76 | return path; | |
77 | } | |
78 | ||
79 | private: | |
80 | LPITEMIDLIST m_pidl; | |
81 | ||
82 | DECLARE_NO_COPY_CLASS(wxItemIdList) | |
83 | }; | |
84 | ||
85 | // enable autocompleting filenames in the text control with given HWND | |
86 | // | |
87 | // this only works on systems with shlwapi.dll 5.0 or later | |
88 | // | |
89 | // implemented in src/msw/utilsgui.cpp | |
90 | extern bool wxEnableFileNameAutoComplete(HWND hwnd); | |
91 | ||
92 | #endif // _WX_MSW_WRAPSHL_H_ | |
93 |