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