]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/wrapshl.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[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
6bb09706
VZ
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
1032aee2
VZ
14#include "wx/msw/wrapwin.h"
15
6bb09706
VZ
16#ifdef __WXWINCE__
17 #include <winreg.h>
18 #include <objbase.h>
19 #include <shlguid.h>
1032aee2 20 #include <shellapi.h>
6bb09706
VZ
21#endif
22
23#include <shlobj.h>
24
5f6475c1
VZ
25#include "wx/msw/winundef.h"
26
13f06c1b
VZ
27#include "wx/log.h"
28
6bb09706
VZ
29// ----------------------------------------------------------------------------
30// wxItemIdList implements RAII on top of ITEMIDLIST
31// ----------------------------------------------------------------------------
32
33class wxItemIdList
34{
35public:
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 {
9a83f860 74 wxLogLastError(wxT("SHGetPathFromIDList"));
6bb09706
VZ
75 }
76
77 return path;
78 }
79
80private:
81 LPITEMIDLIST m_pidl;
82
c0c133e1 83 wxDECLARE_NO_COPY_CLASS(wxItemIdList);
6bb09706
VZ
84};
85
5f6475c1
VZ
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
91extern bool wxEnableFileNameAutoComplete(HWND hwnd);
92
6bb09706
VZ
93#endif // _WX_MSW_WRAPSHL_H_
94