subclassed ShellView window More...
#include <desktop.h>
Public Types | |
typedef ExtContextMenuHandlerT < SubclassedWindow > | super |
Public Member Functions | |
DesktopShellView (HWND hwnd, IShellView *pShellView) | |
bool | InitDragDrop () |
Protected Member Functions | |
LRESULT | WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam) |
int | Command (int id, int code) |
int | Notify (int id, NMHDR *pnmh) |
bool | DoContextMenu (int x, int y) |
HRESULT | DoDesktopContextMenu (int x, int y) |
void | PositionIcons (int dir=1) |
void | refresh () |
Protected Attributes | |
IShellView * | _pShellView |
DesktopDropTarget * | _pDropTarget |
HWND | _hwndListView |
int | _icon_algo |
subclassed ShellView window
Definition at line 168 of file desktop.h.
Reimplemented from ExtContextMenuHandlerT< SubclassedWindow >.
DesktopShellView::DesktopShellView | ( | HWND | hwnd, |
IShellView * | pShellView | ||
) |
Definition at line 487 of file desktop.cpp.
References _hwndListView, _icon_algo, InitDragDrop(), PositionIcons(), and SetWindowStyle.
: super(hwnd), _pShellView(pShellView) { _hwndListView = GetNextWindow(hwnd, GW_CHILD); SetWindowStyle(_hwndListView, GetWindowStyle(_hwndListView)&~LVS_ALIGNMASK);//|LVS_ALIGNTOP|LVS_AUTOARRANGE); // work around for Windows NT, Win 98, ... // Without this the desktop has mysteriously only a size of 800x600 pixels. ClientRect rect(hwnd); MoveWindow(_hwndListView, 0, 0, rect.right, rect.bottom, TRUE); // subclass background window new BackgroundWindow(_hwndListView); _icon_algo = 1; // default icon arrangement PositionIcons(); InitDragDrop(); }
int DesktopShellView::Command | ( | int | id, |
int | code | ||
) | [protected, virtual] |
Reimplemented from SubclassedWindow.
Definition at line 566 of file desktop.cpp.
References SubclassedWindow::Command().
{ return super::Command(id, code); }
bool DesktopShellView::DoContextMenu | ( | int | x, |
int | y | ||
) | [protected] |
Definition at line 576 of file desktop.cpp.
References ExtContextMenuHandlerT< SubclassedWindow >::_cm_ifs, WindowHandle::_hwnd, _pShellView, CHECKERROR, PIDList::GetData(), refresh(), and ShellFolderContextMenu().
Referenced by WndProc().
{ IDataObject* selection; HRESULT hr = _pShellView->GetItemObject(SVGIO_SELECTION, IID_IDataObject, (void**)&selection); if (FAILED(hr)) return false; PIDList pidList; hr = pidList.GetData(selection); if (FAILED(hr)) { selection->Release(); //CHECKERROR(hr); return false; } LPIDA pida = pidList; if (!pida->cidl) { selection->Release(); return false; } LPCITEMIDLIST parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]); LPCITEMIDLIST* apidl = (LPCITEMIDLIST*) alloca(pida->cidl*sizeof(LPCITEMIDLIST)); for(int i=pida->cidl; i>0; --i) apidl[i-1] = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[i]); hr = ShellFolderContextMenu(ShellFolder(parent_pidl), _hwnd, pida->cidl, apidl, x, y, _cm_ifs); selection->Release(); if (SUCCEEDED(hr)) refresh(); else CHECKERROR(hr); return true; }
HRESULT DesktopShellView::DoDesktopContextMenu | ( | int | x, |
int | y | ||
) | [protected] |
Definition at line 618 of file desktop.cpp.
References ExtContextMenuHandlerT< SubclassedWindow >::_cm_ifs, WindowHandle::_hwnd, explorer_about(), IDS_ABOUT_EXPLORER, CtxMenuInterfaces::query_interfaces(), and CtxMenuInterfaces::reset().
Referenced by WndProc().
{ IContextMenu* pcm; HRESULT hr = DesktopFolder()->GetUIObjectOf(_hwnd, 0, NULL, IID_IContextMenu, NULL, (LPVOID*)&pcm); if (SUCCEEDED(hr)) { pcm = _cm_ifs.query_interfaces(pcm); HMENU hmenu = CreatePopupMenu(); if (hmenu) { hr = pcm->QueryContextMenu(hmenu, 0, FCIDM_SHVIEWFIRST, FCIDM_SHVIEWLAST-1, CMF_NORMAL|CMF_EXPLORE); if (SUCCEEDED(hr)) { AppendMenu(hmenu, MF_SEPARATOR, 0, NULL); AppendMenu(hmenu, 0, FCIDM_SHVIEWLAST-1, ResString(IDS_ABOUT_EXPLORER)); UINT idCmd = TrackPopupMenu(hmenu, TPM_LEFTALIGN|TPM_RETURNCMD|TPM_RIGHTBUTTON, x, y, 0, _hwnd, NULL); _cm_ifs.reset(); if (idCmd == FCIDM_SHVIEWLAST-1) { explorer_about(_hwnd); } else if (idCmd) { CMINVOKECOMMANDINFO cmi; cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); cmi.fMask = 0; cmi.hwnd = _hwnd; cmi.lpVerb = (LPCSTR)(INT_PTR)(idCmd - FCIDM_SHVIEWFIRST); cmi.lpParameters = NULL; cmi.lpDirectory = NULL; cmi.nShow = SW_SHOWNORMAL; cmi.dwHotKey = 0; cmi.hIcon = 0; hr = pcm->InvokeCommand(&cmi); } } else _cm_ifs.reset(); DestroyMenu(hmenu); } pcm->Release(); } return hr; }
bool DesktopShellView::InitDragDrop | ( | ) |
Definition at line 509 of file desktop.cpp.
References WindowHandle::_hwnd, _pDropTarget, IDropTargetImpl::AddRef(), IDropTargetImpl::AddSuportedFormat(), CONTEXT, and IDropTargetImpl::Release().
Referenced by DesktopShellView().
{ CONTEXT("DesktopShellView::InitDragDrop()"); _pDropTarget = new DesktopDropTarget(_hwnd); if (!_pDropTarget) return false; _pDropTarget->AddRef(); if (FAILED(RegisterDragDrop(_hwnd, _pDropTarget))) { _pDropTarget->Release(); _pDropTarget = NULL; return false; } else _pDropTarget->Release(); FORMATETC ftetc; ftetc.dwAspect = DVASPECT_CONTENT; ftetc.lindex = -1; ftetc.tymed = TYMED_HGLOBAL; ftetc.cfFormat = CF_HDROP; _pDropTarget->AddSuportedFormat(ftetc); return true; }
int DesktopShellView::Notify | ( | int | id, |
NMHDR * | pnmh | ||
) | [protected, virtual] |
Reimplemented from SubclassedWindow.
Definition at line 571 of file desktop.cpp.
References SubclassedWindow::Notify().
{ return super::Notify(id, pnmh); }
void DesktopShellView::PositionIcons | ( | int | dir = 1 ) |
[protected] |
Definition at line 721 of file desktop.cpp.
References _hwndListView, _icon_algo, ARRANGE_BORDER_DOWN, ARRANGE_BORDER_HV, and ARRANGE_ROUNDABOUT.
Referenced by DesktopShellView(), and WndProc().
{ DWORD spacing = ListView_GetItemSpacing(_hwndListView, FALSE); RECT work_area; SystemParametersInfo(SPI_GETWORKAREA, 0, &work_area, 0); const POINTS& dir1 = s_align_dir1[_icon_algo]; const POINTS& dir2 = s_align_dir2[_icon_algo]; const POINTS& start_pos = s_align_start[_icon_algo]; int dir_x1 = dir1.x; int dir_y1 = dir1.y; int dir_x2 = dir2.x; int dir_y2 = dir2.y; int cx = LOWORD(spacing); int cy = HIWORD(spacing); int dx1 = dir_x1 * cx; int dy1 = dir_y1 * cy; int dx2 = dir_x2 * cx; int dy2 = dir_y2 * cy; int xoffset = (cx-32)/2; int yoffset = 4/*(cy-32)/2*/; int start_x = start_pos.x * (work_area.right - cx) + xoffset; int start_y = start_pos.y * (work_area.bottom - cy) + yoffset; int x = start_x; int y = start_y; int all = ListView_GetItemCount(_hwndListView); int i1, i2; if (dir > 0) { i1 = 0; i2 = all; } else { i1 = all-1; i2 = -1; } IconMap pos_idx; int cnt = 0; int xhv = start_x; int yhv = start_y; for(int idx=i1; idx!=i2; idx+=dir) { pos_idx[IconPos(y, x)] = idx; if (_icon_algo == ARRANGE_BORDER_DOWN) { if (++cnt & 1) x = work_area.right - x - cx + 2*xoffset; else { y += dy1; if (y + cy - 2 * yoffset > work_area.bottom) { y = start_y; start_x += dx2; x = start_x; } } continue; } else if (_icon_algo == ARRANGE_BORDER_HV) { if (++cnt & 1) x = work_area.right - x - cx + 2*xoffset; else if (cnt & 2) { yhv += cy; y = yhv; x = start_x; if (y + cy - 2 * yoffset > work_area.bottom) { start_x += cx; xhv = start_x; x = xhv; start_y += cy; yhv = start_y; y = yhv; } } else { xhv += cx; x = xhv; y = start_y; if (x + cx - 2 * xoffset > work_area.right) { start_x += cx; xhv = start_x; x = xhv; start_y += cy; yhv = start_y; y = yhv; } } continue; } else if (_icon_algo == ARRANGE_ROUNDABOUT) { ///@todo } x += dx1; y += dy1; if (x<0 || x+cx-2*xoffset>work_area.right) { x = start_x; y += dy2; } else if (y<0 || y+cy-2*yoffset>work_area.bottom) { y = start_y; x += dx2; } } // use a little trick to get the icons where we want them to be... //for(IconMap::const_iterator it=pos_idx.end(); --it!=pos_idx.begin(); ) { // const IconPos& pos = it->first; // ListView_SetItemPosition32(_hwndListView, it->second, pos.second, pos.first); //} for(IconMap::const_iterator it=pos_idx.begin(); it!=pos_idx.end(); ++it) { const IconPos& pos = it->first; ListView_SetItemPosition32(_hwndListView, it->second, pos.second, pos.first); } }
void DesktopShellView::refresh | ( | ) | [protected] |
Definition at line 855 of file desktop.cpp.
Referenced by DoContextMenu().
{
///@todo
}
LRESULT DesktopShellView::WndProc | ( | UINT | nmsg, |
WPARAM | wparam, | ||
LPARAM | lparam | ||
) | [protected, virtual] |
Reimplemented from ExtContextMenuHandlerT< SubclassedWindow >.
Definition at line 540 of file desktop.cpp.
References _hwndListView, _icon_algo, DoContextMenu(), DoDesktopContextMenu(), PM_DISPLAY_VERSION, PM_GET_ICON_ALGORITHM, PM_SET_ICON_ALGORITHM, PositionIcons(), and ExtContextMenuHandlerT< SubclassedWindow >::WndProc().
{ switch(nmsg) { case WM_CONTEXTMENU: if (!DoContextMenu(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam))) DoDesktopContextMenu(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); break; case PM_SET_ICON_ALGORITHM: _icon_algo = wparam; PositionIcons(); break; case PM_GET_ICON_ALGORITHM: return _icon_algo; case PM_DISPLAY_VERSION: return SendMessage(_hwndListView, nmsg, wparam, lparam); default: return super::WndProc(nmsg, wparam, lparam); } return 0; }
HWND DesktopShellView::_hwndListView [protected] |
Definition at line 190 of file desktop.h.
Referenced by DesktopShellView(), PositionIcons(), and WndProc().
int DesktopShellView::_icon_algo [protected] |
Definition at line 191 of file desktop.h.
Referenced by DesktopShellView(), PositionIcons(), and WndProc().
DesktopDropTarget* DesktopShellView::_pDropTarget [protected] |
Definition at line 189 of file desktop.h.
Referenced by InitDragDrop().
IShellView* DesktopShellView::_pShellView [protected] |
Definition at line 177 of file desktop.h.
Referenced by DoContextMenu().
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |