]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/wrapshl.h
fix wxMotif errors when linking against a wxControlWithItems-derived widget
[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 // 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 #include "wx/log.h"
29
30 // ----------------------------------------------------------------------------
31 // wxItemIdList implements RAII on top of ITEMIDLIST
32 // ----------------------------------------------------------------------------
33
34 class wxItemIdList
35 {
36 public:
37 // ctor takes ownership of the item and will free it
38 wxItemIdList(LPITEMIDLIST pidl)
39 {
40 m_pidl = pidl;
41 }
42
43 static void Free(LPITEMIDLIST pidl)
44 {
45 if ( pidl )
46 {
47 LPMALLOC pMalloc;
48 SHGetMalloc(&pMalloc);
49 if ( pMalloc )
50 {
51 pMalloc->Free(pidl);
52 pMalloc->Release();
53 }
54 else
55 {
56 wxLogLastError(wxT("SHGetMalloc"));
57 }
58 }
59 }
60
61 ~wxItemIdList()
62 {
63 Free(m_pidl);
64 }
65
66 // implicit conversion to LPITEMIDLIST
67 operator LPITEMIDLIST() const { return m_pidl; }
68
69 // get the corresponding path, returns empty string on error
70 wxString GetPath() const
71 {
72 wxString path;
73 if ( !SHGetPathFromIDList(m_pidl, wxStringBuffer(path, MAX_PATH)) )
74 {
75 wxLogLastError(_T("SHGetPathFromIDList"));
76 }
77
78 return path;
79 }
80
81 private:
82 LPITEMIDLIST m_pidl;
83
84 DECLARE_NO_COPY_CLASS(wxItemIdList)
85 };
86
87 // enable autocompleting filenames in the text control with given HWND
88 //
89 // this only works on systems with shlwapi.dll 5.0 or later
90 //
91 // implemented in src/msw/utilsgui.cpp
92 extern bool wxEnableFileNameAutoComplete(HWND hwnd);
93
94 #endif // _WX_MSW_WRAPSHL_H_
95