00001 /* 00002 * Copyright 2003, 2004 Martin Fuchs 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 */ 00018 00019 00020 // 00021 // Explorer clone 00022 // 00023 // desktop.h 00024 // 00025 // Martin Fuchs, 09.08.2003 00026 // 00027 00028 00029 #define PM_SET_ICON_ALGORITHM (WM_APP+0x19) 00030 #define PM_GET_ICON_ALGORITHM (WM_APP+0x1A) 00031 #define PM_DISPLAY_VERSION (WM_APP+0x24) 00032 00033 00034 /// subclassed background window behind the visible desktop window 00035 struct BackgroundWindow : public SubclassedWindow 00036 { 00037 typedef SubclassedWindow super; 00038 00039 BackgroundWindow(HWND hwnd); 00040 00041 protected: 00042 LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); 00043 00044 void DrawDesktopBkgnd(HDC hdc); 00045 00046 int _display_version; 00047 }; 00048 00049 00050 /// Implementation of the Explorer desktop window 00051 struct DesktopWindow : public Window, public IShellBrowserImpl 00052 { 00053 typedef Window super; 00054 00055 DesktopWindow(HWND hwnd); 00056 ~DesktopWindow(); 00057 00058 static HWND Create(); 00059 00060 virtual HRESULT STDMETHODCALLTYPE GetWindow(HWND* lphwnd) 00061 { 00062 *lphwnd = _hwnd; 00063 return S_OK; 00064 } 00065 00066 virtual HRESULT STDMETHODCALLTYPE QueryActiveShellView(IShellView** ppshv) 00067 { 00068 _pShellView->AddRef(); 00069 *ppshv = _pShellView; 00070 return S_OK; 00071 } 00072 00073 virtual HRESULT STDMETHODCALLTYPE GetControlWindow(UINT id, HWND* lphwnd) 00074 { 00075 return E_NOTIMPL; 00076 } 00077 00078 virtual HRESULT STDMETHODCALLTYPE SendControlMsg(UINT id, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* pret) 00079 { 00080 return E_NOTIMPL; 00081 } 00082 00083 protected: 00084 LRESULT Init(LPCREATESTRUCT pcs); 00085 LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); 00086 00087 IShellView* _pShellView; 00088 WindowHandle _desktopBar; 00089 00090 virtual HRESULT OnDefaultCommand(LPIDA pida); 00091 }; 00092 00093 00094 /// OLE drop target for the desktop window 00095 class DesktopDropTarget : public IDropTargetImpl 00096 { 00097 typedef IDropTargetImpl super; 00098 00099 public: 00100 DesktopDropTarget(HWND hTargetWnd) : super(hTargetWnd) {} 00101 00102 virtual bool OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD *pdwEffect) 00103 { 00104 if (pFmtEtc->cfFormat==CF_HDROP && medium.tymed==TYMED_HGLOBAL) { 00105 HDROP hDrop = (HDROP)GlobalLock(medium.hGlobal); 00106 00107 if (hDrop) { 00108 TCHAR szFileName[MAX_PATH]; 00109 00110 UINT cFiles = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0); 00111 00112 for(UINT i=0; i<cFiles; ++i) { 00113 DragQueryFile(hDrop, i, szFileName, sizeof(szFileName)); 00114 00115 if (DROPEFFECT_COPY & *pdwEffect) { 00116 // copy the file or dir 00117 00118 ///@todo Add the code to handle Copy 00119 00120 } else if (DROPEFFECT_MOVE & *pdwEffect) { 00121 // move the file or dir 00122 00123 ///@todo Add the code to handle Move 00124 00125 } 00126 } 00127 //DragFinish(hDrop); // base class calls ReleaseStgMedium 00128 } 00129 00130 GlobalUnlock(medium.hGlobal); 00131 } 00132 00133 //@@TreeView_SelectDropTarget(m_hTargetWnd, NULL); 00134 00135 return true; //let base free the medium 00136 } 00137 00138 virtual HRESULT STDMETHODCALLTYPE DragOver( 00139 /* [in] */ DWORD grfKeyState, 00140 /* [in] */ POINTL pt, 00141 /* [out][in] */ DWORD __RPC_FAR *pdwEffect) 00142 { 00143 TVHITTESTINFO hit; 00144 hit.pt = (POINT&)pt; 00145 ScreenToClient(m_hTargetWnd, &hit.pt); 00146 hit.flags = TVHT_ONITEM; 00147 00148 /*@@ 00149 HTREEITEM hItem = TreeView_HitTest(m_hTargetWnd,&hit); 00150 00151 if (hItem != NULL) 00152 TreeView_SelectDropTarget(m_hTargetWnd, hItem); 00153 */ 00154 00155 return super::DragOver(grfKeyState, pt, pdwEffect); 00156 } 00157 00158 virtual HRESULT STDMETHODCALLTYPE DragLeave(void) 00159 { 00160 //@@ TreeView_SelectDropTarget(m_hTargetWnd, NULL); 00161 00162 return super::DragLeave(); 00163 } 00164 }; 00165 00166 00167 /// subclassed ShellView window 00168 struct DesktopShellView : public ExtContextMenuHandlerT<SubclassedWindow> 00169 { 00170 typedef ExtContextMenuHandlerT<SubclassedWindow> super; 00171 00172 DesktopShellView(HWND hwnd, IShellView* pShellView); 00173 00174 bool InitDragDrop(); 00175 00176 protected: 00177 IShellView* _pShellView; 00178 00179 LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); 00180 int Command(int id, int code); 00181 int Notify(int id, NMHDR* pnmh); 00182 00183 bool DoContextMenu(int x, int y); 00184 HRESULT DoDesktopContextMenu(int x, int y); 00185 void PositionIcons(int dir=1); 00186 00187 void refresh(); 00188 00189 DesktopDropTarget* _pDropTarget; 00190 HWND _hwndListView; 00191 int _icon_algo; 00192 };
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |