2 * Copyright 2003, 2004 Martin Fuchs
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 // Martin Fuchs, 09.08.2003
29 #define PM_SET_ICON_ALGORITHM (WM_APP+0x19)
30 #define PM_GET_ICON_ALGORITHM (WM_APP+0x1A)
31 #define PM_DISPLAY_VERSION (WM_APP+0x24)
34 /// subclassed background window behind the visible desktop window
35 struct BackgroundWindow
: public SubclassedWindow
37 typedef SubclassedWindow super
;
39 BackgroundWindow(HWND hwnd
);
42 LRESULT
WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
44 void DrawDesktopBkgnd(HDC hdc
);
50 /// Implementation of the Explorer desktop window
51 struct DesktopWindow
: public PreTranslateWindow
, public IShellBrowserImpl
53 typedef PreTranslateWindow super
;
55 DesktopWindow(HWND hwnd
);
60 virtual HRESULT STDMETHODCALLTYPE
GetWindow(HWND
* lphwnd
)
66 virtual HRESULT STDMETHODCALLTYPE
QueryActiveShellView(IShellView
** ppshv
)
68 _pShellView
->AddRef();
73 virtual HRESULT STDMETHODCALLTYPE
GetControlWindow(UINT id
, HWND
* lphwnd
)
78 virtual HRESULT STDMETHODCALLTYPE
SendControlMsg(UINT id
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, LRESULT
* pret
)
84 LRESULT
Init(LPCREATESTRUCT pcs
);
85 LRESULT
WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
87 IShellView
* _pShellView
;
88 WindowHandle _desktopBar
;
90 virtual HRESULT
OnDefaultCommand(LPIDA pida
);
94 /// OLE drop target for the desktop window
95 class DesktopDropTarget
: public IDropTargetImpl
97 typedef IDropTargetImpl super
;
100 DesktopDropTarget(HWND hTargetWnd
) : super(hTargetWnd
) {}
102 virtual bool OnDrop(FORMATETC
* pFmtEtc
, STGMEDIUM
& medium
, DWORD
*pdwEffect
)
104 if (pFmtEtc
->cfFormat
==CF_HDROP
&& medium
.tymed
==TYMED_HGLOBAL
) {
105 HDROP hDrop
= (HDROP
)GlobalLock(medium
.hGlobal
);
108 TCHAR szFileName
[MAX_PATH
];
110 UINT cFiles
= DragQueryFile(hDrop
, 0xFFFFFFFF, NULL
, 0);
112 for(UINT i
=0; i
<cFiles
; ++i
) {
113 DragQueryFile(hDrop
, i
, szFileName
, sizeof(szFileName
) / sizeof(szFileName
[0]));
115 if (DROPEFFECT_COPY
& *pdwEffect
) {
116 // copy the file or dir
118 ///@todo Add the code to handle Copy
120 } else if (DROPEFFECT_MOVE
& *pdwEffect
) {
121 // move the file or dir
123 ///@todo Add the code to handle Move
127 //DragFinish(hDrop); // base class calls ReleaseStgMedium
130 GlobalUnlock(medium
.hGlobal
);
133 //@@TreeView_SelectDropTarget(m_hTargetWnd, NULL);
135 return true; //let base free the medium
138 virtual HRESULT STDMETHODCALLTYPE
DragOver(
139 /* [in] */ DWORD grfKeyState
,
140 /* [in] */ POINTL pt
,
141 /* [out][in] */ DWORD __RPC_FAR
*pdwEffect
)
146 ScreenToClient(m_hTargetWnd
, &hit
.pt
);
147 hit
.flags
= TVHT_ONITEM
;
150 HTREEITEM hItem = TreeView_HitTest(m_hTargetWnd,&hit);
153 TreeView_SelectDropTarget(m_hTargetWnd, hItem);
156 return super::DragOver(grfKeyState
, pt
, pdwEffect
);
159 virtual HRESULT STDMETHODCALLTYPE
DragLeave(void)
161 //@@ TreeView_SelectDropTarget(m_hTargetWnd, NULL);
163 return super::DragLeave();
168 /// subclassed ShellView window
169 struct DesktopShellView
: public ExtContextMenuHandlerT
<SubclassedWindow
>
171 typedef ExtContextMenuHandlerT
<SubclassedWindow
> super
;
173 DesktopShellView(HWND hwnd
, IShellView
* pShellView
);
179 IShellView
* _pShellView
;
181 LRESULT
WndProc(UINT nmsg
, WPARAM wparam
, LPARAM lparam
);
182 int Command(int id
, int code
);
183 int Notify(int id
, NMHDR
* pnmh
);
185 bool DoContextMenu(int x
, int y
);
186 HRESULT
DoDesktopContextMenu(int x
, int y
);
187 void PositionIcons(int dir
=1);