1 //*******************************************************************************
4 // You may use this source code, compile or redistribute it as part of your application
5 // for free. You cannot redistribute it as a part of a software development
6 // library without the agreement of the author. If the sources are
7 // distributed along with the application, you should leave the original
8 // copyright notes in the source code without any changes.
9 // This code can be used WITHOUT ANY WARRANTIES at your own risk.
11 // For the latest updates to this code, check this site:
12 // http://www.masmex.com
15 // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
16 //*******************************************************************************
18 #ifndef __IESHELLLISTCTRL_H__
19 #define __IESHELLLISTCTRL_H__
27 #endif // _MSC_VER > 1000
29 typedef struct SLC_COLUMN_DATA
31 SLC_COLUMN_DATA() { pidl = NULL; iImage = -1;}
35 } SLC_COLUMN_DATA, *PSLC_COLUMN_DATA;
39 // IEShellListCtrl.h : header file
43 #include "ShellPidl.h"
44 #include "ShellDetails.h"
45 #include "ShellSettings.h"
47 #include "IEShellDragDrop.h"
48 /////////////////////////////////////////////////////////////////////////////
49 // CIEShellListCtrl window
52 typedef vector<LPLVITEMDATA> vecListItemData;
54 class CTRL_EXT_CLASS CIEShellListCtrl : public CUIODListCtrl
70 void SetFileFilter(LPCTSTR pszFilter) { m_sFileFilter = pszFilter; }
71 CString GetFileFilter() { return m_sFileFilter.IsEmpty() ? _T("*.*") : m_sFileFilter; }
72 void SetNotifyParent(bool bNotifyParent) { m_bNotifyParent = bNotifyParent; }
73 void NoExtAllowed() { m_bNoExt = true; }
74 void ExcludeFileType(LPCTSTR pszType) { m_ExcludedLookup.AddHead(pszType); }
75 CStringList &GetExcludedFileTypes() { return m_ExcludedLookup; }
76 void FillExcludedFileTypes(CComboBox &cb);
77 void SetExcludedFileTypes(CComboBox &cb);
78 bool RefreshAllowed() { return m_bRefreshAllowed; }
79 void SetRefreshAllowed(bool bRefresh) { m_bRefreshAllowed = bRefresh; }
80 CShellPidl &GetShellPidl() { return m_ShellPidl; }
81 LPMALLOC GetMalloc() { return m_pMalloc; }
82 LPTVITEMDATA GetTVID() { return &m_tvid; }
83 LPSHELLFOLDER GetShellFolder() { return m_tvid.lpsfParent; }
84 bool GetCallBack() { return m_bCallBack; }
85 CString GetPathName(int nRow);
86 CString GetCurrPathName();
87 LPCITEMIDLIST GetPathPidl(int nRow);
88 const CShellSettings &GetShellSettings() const;
89 CShellSettings &GetShellSettings();
92 virtual void PopupTheMenu(int nRow,CPoint point);
93 virtual void ShellExecute(int nRow,LPCTSTR pszVerb=NULL);
94 virtual void SetNotificationObject(bool bNotify);
95 virtual BOOL Populate(LPTVITEMDATA lptvid,LPSHELLFOLDER psfFolder,bool bCallBack);
96 virtual BOOL Populate(LPCTSTR pszPath, bool bCallBack=false);
97 virtual BOOL Populate(LPTVITEMDATA lptvid);
98 virtual void Refresh();
99 virtual void StartPopulate();
100 virtual void EndPopulate();
103 virtual void DestroyThreads();
105 virtual void SetColumnWidths();
106 virtual void RemoveExt(LPTSTR pszFileName);
107 virtual void InitColumns();
108 virtual CString GetColumns();
109 virtual BOOL InitImageLists();
110 virtual BOOL InitItems(LPTVITEMDATA lptvid, bool bCallBack);
111 virtual void InitShellSettings();
112 virtual bool FilterItem(LPSHELLFOLDER pFolder,LPCITEMIDLIST pidl,UINT ulAttrs);
113 virtual bool GetColText(int nCol,LPCITEMIDLIST pidlAbs,LPLVITEMDATA lplvid,CString &sText);
114 virtual void GetText(PSLC_COLUMN_DATA pColData,LV_DISPINFO *pDispInfo,LPLVITEMDATA lplvid);
115 virtual void GetFileDetails(LPCITEMIDLIST pidl, CString &sSize, CString &sDateTime);
116 virtual void CreateFileChangeThread(HWND hwnd);
117 virtual void FreeTVID();
118 virtual void FreeInterface(IUnknown *pInterface);
119 virtual bool UseShellColumns();
120 virtual LPCTSTR GetFilterMask(LPCTSTR pszFilter,CString &sMask);
122 void LoadFilterFiles(const CString &sFileFilter);
124 // ClassWizard generated virtual function overrides
125 //{{AFX_VIRTUAL(CIEShellListCtrl)
127 virtual void ChangeStyle(UINT &dwStyle);
130 virtual void GoBack(int nRow);
131 virtual void ShowPopupMenu(int nRow,int nCol,CPoint point);
132 virtual BOOL OnEnter(NM_LISTVIEW* pNMListView);
133 virtual BOOL DoubleClick(NM_LISTVIEW* pNMListView);
134 virtual void PreSubclassWindow();
135 virtual bool DragOver(CDD_OleDropTargetInfo *pInfo);
136 virtual bool DragLeave(CDD_OleDropTargetInfo *pInfo);
137 virtual bool DragEnter(CDD_OleDropTargetInfo *pInfo);
138 virtual bool DragDrop(CDD_OleDropTargetInfo *pInfo);
139 virtual BOOL GetDispInfo(LV_DISPINFO *pDispInfo);
140 virtual PFNLVCOMPARE GetCompareFunc();
141 virtual void AllItemsDeleted();
142 virtual DROPEFFECT DoDragDrop(int *pnRows,COleDataSource *pOleDataSource);
143 virtual bool EndLabelEdit(int nRow,int nCol,LPCTSTR pszText);
147 virtual ~CIEShellListCtrl();
149 // Generated message map functions
151 //{{AFX_MSG(CIEShellListCtrl)
152 // NOTE - the ClassWizard will add and remove member functions here.
153 afx_msg void OnDestroy();
154 afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
155 afx_msg LRESULT OnAppFileChangeNewPath(WPARAM wParam, LPARAM lParam);
156 afx_msg LRESULT OnAppFileChangeEvent(WPARAM wParam, LPARAM lParam);
157 afx_msg LRESULT OnAppUpdateAllViews(WPARAM wParam, LPARAM lParam );
158 afx_msg LRESULT OnSettingChange(WPARAM wParam,LPARAM lParam);
159 afx_msg LRESULT OnSetmessagestring(WPARAM wParam, LPARAM lParam );
161 afx_msg LRESULT OnAppDeleteKey(WPARAM wParam, LPARAM lParam);
162 afx_msg LRESULT OnAppPropertiesKey(WPARAM wParam, LPARAM lParam);
163 DECLARE_MESSAGE_MAP()
165 static UINT ThreadFunc (LPVOID pParam);
166 enum { MAX_THREADS=1 };
168 vecListItemData m_vecItemData;
169 CShellPidl m_ShellPidl;
171 LPSHELLFOLDER m_psfSubFolder;
172 LPITEMIDLIST m_pidlInternet;
174 HANDLE m_hThreads[MAX_THREADS];
175 CWinThread *m_pThreads[MAX_THREADS];
176 CEvent m_event[MAX_THREADS];
177 CEvent m_MonitorEvent[MAX_THREADS];
178 CString m_sMonitorPath;
179 CIEShellDragDrop m_ShellDragDrop;
180 CShellDetails m_ShellDetails;
181 CShellSettings m_ShellSettings;
183 CString m_sFileFilter;
184 CStringList m_FilterLookup;
185 CStringList m_ExcludedLookup;
189 bool m_bRefreshAllowed;
190 bool m_bPopulateInit;
192 bool m_bNotifyParent;
194 /////////////////////////////////////////////////////////////////////////////
195 typedef struct FC_THREADINFO
198 HANDLE hMonitorEvent;
199 CIEShellListCtrl *pListCtrl;
200 } FC_THREADINFO, *PFC_THREADINFO;
202 inline const CShellSettings &CIEShellListCtrl::GetShellSettings() const
204 return m_ShellSettings;
207 inline CShellSettings &CIEShellListCtrl::GetShellSettings()
209 return m_ShellSettings;
212 //{{AFX_INSERT_LOCATION}}
213 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
215 #endif //__IESHELLLISTCTRL_H__