]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/wrapshl.h
add missing sample stc
[wxWidgets.git] / include / wx / msw / wrapshl.h
CommitLineData
6bb09706
VZ
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
1032aee2
VZ
15#include "wx/msw/wrapwin.h"
16
6bb09706
VZ
17#ifdef __WXWINCE__
18 #include <winreg.h>
19 #include <objbase.h>
20 #include <shlguid.h>
1032aee2 21 #include <shellapi.h>
6bb09706
VZ
22#endif
23
24#include <shlobj.h>
25
5f6475c1
VZ
26#include "wx/msw/winundef.h"
27
6bb09706
VZ
28// ----------------------------------------------------------------------------
29// wxItemIdList implements RAII on top of ITEMIDLIST
30// ----------------------------------------------------------------------------
31
32class wxItemIdList
33{
34public:
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
79private:
80 LPITEMIDLIST m_pidl;
81
82 DECLARE_NO_COPY_CLASS(wxItemIdList)
83};
84
5f6475c1
VZ
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
90extern bool wxEnableFileNameAutoComplete(HWND hwnd);
91
6bb09706
VZ
92#endif // _WX_MSW_WRAPSHL_H_
93