]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/wrapshl.h
more warning fixes about empty if statement in helper classes in release build
[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
15#ifdef __WXWINCE__
16 #include <winreg.h>
17 #include <objbase.h>
18 #include <shlguid.h>
19#endif
20
21#include <shlobj.h>
22
5f6475c1
VZ
23#include "wx/msw/winundef.h"
24
6bb09706
VZ
25// ----------------------------------------------------------------------------
26// wxItemIdList implements RAII on top of ITEMIDLIST
27// ----------------------------------------------------------------------------
28
29class wxItemIdList
30{
31public:
32 // ctor takes ownership of the item and will free it
33 wxItemIdList(LPITEMIDLIST pidl)
34 {
35 m_pidl = pidl;
36 }
37
38 static void Free(LPITEMIDLIST pidl)
39 {
40 if ( pidl )
41 {
42 LPMALLOC pMalloc;
43 SHGetMalloc(&pMalloc);
44 if ( pMalloc )
45 {
46 pMalloc->Free(pidl);
47 pMalloc->Release();
48 }
49 else
50 {
51 wxLogLastError(wxT("SHGetMalloc"));
52 }
53 }
54 }
55
56 ~wxItemIdList()
57 {
58 Free(m_pidl);
59 }
60
61 // implicit conversion to LPITEMIDLIST
62 operator LPITEMIDLIST() const { return m_pidl; }
63
64 // get the corresponding path, returns empty string on error
65 wxString GetPath() const
66 {
67 wxString path;
68 if ( !SHGetPathFromIDList(m_pidl, wxStringBuffer(path, MAX_PATH)) )
69 {
70 wxLogLastError(_T("SHGetPathFromIDList"));
71 }
72
73 return path;
74 }
75
76private:
77 LPITEMIDLIST m_pidl;
78
79 DECLARE_NO_COPY_CLASS(wxItemIdList)
80};
81
5f6475c1
VZ
82// enable autocompleting filenames in the text control with given HWND
83//
84// this only works on systems with shlwapi.dll 5.0 or later
85//
86// implemented in src/msw/utilsgui.cpp
87extern bool wxEnableFileNameAutoComplete(HWND hwnd);
88
6bb09706
VZ
89#endif // _WX_MSW_WRAPSHL_H_
90