]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/wrapshl.h
removed wxDCWindowImpl::m_win; use wxDCImpl::m_window instead (fixes caret-related...
[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
13f06c1b
VZ
28#include "wx/log.h"
29
6bb09706
VZ
30// ----------------------------------------------------------------------------
31// wxItemIdList implements RAII on top of ITEMIDLIST
32// ----------------------------------------------------------------------------
33
34class wxItemIdList
35{
36public:
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
81private:
82 LPITEMIDLIST m_pidl;
83
84 DECLARE_NO_COPY_CLASS(wxItemIdList)
85};
86
5f6475c1
VZ
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
92extern bool wxEnableFileNameAutoComplete(HWND hwnd);
93
6bb09706
VZ
94#endif // _WX_MSW_WRAPSHL_H_
95