]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/dirdlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDirDialog
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dirdlg.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/dialog.h"
28 #include "wx/dirdlg.h"
31 #if defined(__WIN95__) && !defined(__GNUWIN32__)
32 #include "shlobj.h" // Win95 shell
35 #include "wx/msw/private.h"
36 #include "wx/cmndata.h"
42 #define wxDIALOG_DEFAULT_X 300
43 #define wxDIALOG_DEFAULT_Y 300
45 #if !USE_SHARED_LIBRARY
46 IMPLEMENT_CLASS(wxDirDialog
, wxDialog
)
49 wxDirDialog::wxDirDialog(wxWindow
*parent
, const wxString
& message
,
50 // const wxString& caption,
51 const wxString
& defaultPath
,
52 long style
, const wxPoint
& pos
)
55 // m_caption = caption;
56 m_dialogStyle
= style
;
61 int wxDirDialog::ShowModal(void)
63 // Unfortunately Gnu-Win32 doesn't yet have COM support
64 #if defined(__WIN95__) && !defined(__GNUWIN32__)
66 if (m_parent
) hWnd
= (HWND
) m_parent
->GetHWND();
70 // LPITEMIDLIST pidlPrograms; // PIDL for Programs folder
71 LPITEMIDLIST pidlBrowse
; // PIDL selected by user
72 LPMALLOC pMalloc
= NULL
;
74 HRESULT result
= ::SHGetMalloc(&pMalloc
);
76 if (result
!= NOERROR
)
79 // Allocate a buffer to receive browse information.
80 if ((lpBuffer
= (LPSTR
) pMalloc
->Alloc(MAX_PATH
)) == NULL
)
87 // Get the PIDL for the Programs folder.
88 if (!SUCCEEDED(SHGetSpecialFolderLocation(
89 parent->GetSafeHwnd(), CSIDL_PROGRAMS, &pidlPrograms))) {
90 pMalloc->Free(lpBuffer);
96 // Fill in the BROWSEINFO structure.
98 bi
.pidlRoot
= NULL
; // pidlPrograms;
99 bi
.pszDisplayName
= lpBuffer
;
100 bi
.lpszTitle
= (LPCTSTR
) (const char *) m_message
;
105 // Browse for a folder and return its PIDL.
106 pidlBrowse
= SHBrowseForFolder(&bi
);
109 if (pidlBrowse
!= NULL
) {
111 // Show the display name, title, and file system path.
112 if (SHGetPathFromIDList(pidlBrowse
, lpBuffer
))
115 // Free the PIDL returned by SHBrowseForFolder.
116 pMalloc
->Free(pidlBrowse
);
122 // pMalloc->Free(pidlPrograms);
123 pMalloc
->Free(lpBuffer
);