📄 desktop.c
字号:
IShellFolder_Release(psfDesktopFolder);
if (csfv.psfvcb != NULL)
csfv.psfvcb->lpVtbl->Release(csfv.psfvcb);
#endif
if (!SUCCEEDED(hr))
goto Fail;
hr = IShellView_QueryInterface(This->DesktopView,
&IID_IShellView2,
(PVOID*)&This->DesktopView2);
if (!SUCCEEDED(hr))
This->DesktopView2 = NULL;
if (lpCreateStruct == NULL)
{
if (!GetClientRect(This->hWnd,
&rcClient))
{
goto Fail;
}
}
else
{
rcClient.left = 0;
rcClient.top = 0;
rcClient.right = lpCreateStruct->cx;
rcClient.bottom = lpCreateStruct->cy;
}
fs.ViewMode = FVM_ICON;
fs.fFlags = FWF_DESKTOP | FWF_NOCLIENTEDGE | FWF_NOSCROLL | FWF_TRANSPARENT;
if (This->DesktopView2 != NULL)
{
SV2CVW2_PARAMS params;
params.cbSize = sizeof(params);
params.psvPrev = NULL;
params.pfs = &fs;
params.psbOwner = ShellBrowser;
params.prcView = &rcClient;
params.pvid = &VID_LargeIcons;
hr = IShellView2_CreateViewWindow2(This->DesktopView2,
¶ms);
if (FAILED(hr))
goto DefCreateViewWindow;
This->hWndShellView = params.hwndView;
}
else
{
DefCreateViewWindow:
hr = IShellView_CreateViewWindow(This->DesktopView,
NULL,
&fs,
ShellBrowser,
&rcClient,
&This->hWndShellView);
}
if (!SUCCEEDED(hr))
goto Fail;
IShellView_EnableModeless(This->DesktopView,
TRUE);
hr = IShellView_UIActivate(This->DesktopView,
SVUIA_ACTIVATE_FOCUS);
if (!SUCCEEDED(hr))
{
IShellView_DestroyViewWindow(This->DesktopView);
Fail:
/* NOTE: the other references will be released in the
WM_NCDESTROY handler! */
IDesktopShellBrowserImpl_Release(ShellBrowser);
return NULL;
}
/* Now get the real window handle to the list view control!
We need to assume it is the child window of the default
shell view window. There doesn't seem to be another way
to get to the list view window handle... */
This->hWndDesktopListView = FindWindowEx(This->hWndShellView,
NULL,
WC_LISTVIEW,
NULL);
if (This->hWndDesktopListView != NULL)
{
/* Register drag&drop */
hr = IShellView_QueryInterface(This->DesktopView,
&IID_IDropTarget,
(PVOID*)&This->DropTarget);
if (SUCCEEDED(hr))
{
hr = RegisterDragDrop(This->hWndDesktopListView,
This->DropTarget);
if (!SUCCEEDED(hr))
{
IDropTarget_Release(This->DropTarget);
This->DropTarget = NULL;
}
}
}
/* Register a notification that is triggered when a new drive is added and the shell
should open that drive in a new window, such as USB sticks. */
cne.pidl = NULL;
cne.fRecursive = TRUE;
This->ChangeNotificationId = SHChangeNotifyRegister(This->hWnd,
SHCNRF_ShellLevel | SHCNRF_NewDelivery,
SHCNE_DRIVEADDGUI,
WM_SHELL_ADDDRIVENOTIFY,
1,
&cne);
/* Create the tray window */
This->Tray = CreateTrayWindow(This->hWnd);
return This;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_GetWindow(IN OUT IShellBrowser *iface,
OUT HWND *phwnd)
{
IDesktopShellBrowserImpl *This = impl_from_IShellBrowser(iface);
if (This->hWnd != NULL)
{
*phwnd = This->hWnd;
return S_OK;
}
*phwnd = NULL;
return E_UNEXPECTED;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_ContextSensitiveHelp(IN OUT IShellBrowser *iface,
IN BOOL fEnterMode)
{
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_InsertMenusSB(IN OUT IShellBrowser *iface,
IN HMENU hmenuShared,
OUT LPOLEMENUGROUPWIDTHS lpMenuWidths)
{
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_SetMenuSB(IN OUT IShellBrowser *iface,
IN HMENU hmenuShared,
IN HOLEMENU holemenuRes,
IN HWND hwndActiveObject)
{
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_RemoveMenusSB(IN OUT IShellBrowser *iface,
IN HMENU hmenuShared)
{
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_SetStatusTextSB(IN OUT IShellBrowser *iface,
IN LPCOLESTR lpszStatusText)
{
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_EnableModelessSB(IN OUT IShellBrowser *iface,
IN BOOL fEnable)
{
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_TranslateAcceleratorSB(IN OUT IShellBrowser *iface,
IN LPMSG lpmsg,
IN WORD wID)
{
return S_FALSE;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_BrowseObject(IN OUT IShellBrowser *iface,
IN LPCITEMIDLIST pidl,
IN UINT wFlags)
{
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_GetViewStateStream(IN OUT IShellBrowser *iface,
IN DWORD grfMode,
OUT IStream **ppStrm)
{
IDesktopShellBrowserImpl *This = impl_from_IShellBrowser(iface);
static WCHAR szItemPos[] = L"ItemPos";
HRESULT hRet;
IPropertyBag *PropBag = NULL;
WCHAR szPropName[64];
/* Determine the name of the property that contains the stream of
icon positions */
wcscpy(szPropName,
szItemPos);
hRet = SHGetPerScreenResName(szPropName + wcslen(szPropName),
(sizeof(szPropName) / sizeof(szPropName[0])) - wcslen(szPropName),
0);
if (SUCCEEDED(hRet))
{
/* Locate the property bag for the desktop */
hRet = SHGetViewStatePropertyBag(This->pidlDesktop,
L"Desktop",
SHGVSPB_FOLDERNODEFAULTS | SHGVSPB_ROAM,
&IID_IPropertyBag,
(PVOID*)&PropBag);
if (SUCCEEDED(hRet))
{
/* Create a stream for the ItemPos property */
hRet = SHPropertyBag_ReadStream(PropBag,
szPropName,
ppStrm);
IPropertyBag_Release(PropBag);
if (SUCCEEDED(hRet))
{
/* FIXME: For some reason the shell doesn't position the icons... */
}
}
}
return hRet;
}
static HWND
DesktopGetWindowControl(IN IDesktopShellBrowserImpl *This,
IN UINT id)
{
switch (id)
{
case FCW_TOOLBAR:
case FCW_STATUS:
case FCW_TREE:
case FCW_PROGRESS:
return NULL;
default:
return NULL;
}
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_GetControlWindow(IN OUT IShellBrowser *iface,
IN UINT id,
OUT HWND *lphwnd)
{
IDesktopShellBrowserImpl *This = impl_from_IShellBrowser(iface);
HWND hWnd;
hWnd = DesktopGetWindowControl(This,
id);
if (hWnd != NULL)
{
*lphwnd = hWnd;
return S_OK;
}
*lphwnd = NULL;
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_SendControlMsg(IN OUT IShellBrowser *iface,
IN UINT id,
IN UINT uMsg,
IN WPARAM wParam,
IN LPARAM lParam,
OUT LRESULT *pret)
{
IDesktopShellBrowserImpl *This = impl_from_IShellBrowser(iface);
HWND hWnd;
if (pret == NULL)
return E_POINTER;
hWnd = DesktopGetWindowControl(This,
id);
if (hWnd != NULL)
{
*pret = SendMessage(hWnd,
uMsg,
wParam,
lParam);
return S_OK;
}
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_QueryActiveShellView(IN OUT IShellBrowser *iface,
OUT IShellView **ppshv)
{
IShellView *ActiveView;
IDesktopShellBrowserImpl *This = impl_from_IShellBrowser(iface);
ActiveView = This->DesktopView;
IDesktopShellBrowserImpl_AddRef(iface);
*ppshv = ActiveView;
return S_OK;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_OnViewWindowActive(IN OUT IShellBrowser *iface,
IN OUT IShellView *ppshv)
{
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_SetToolbarItems(IN OUT IShellBrowser *iface,
IN LPTBBUTTON lpButtons,
IN UINT nButtons,
IN UINT uFlags)
{
return E_NOTIMPL;
}
static const IShellBrowserVtbl IDesktopShellBrowserImpl_Vtbl =
{
/* IUnknown */
IDesktopShellBrowserImpl_QueryInterface,
IDesktopShellBrowserImpl_AddRef,
IDesktopShellBrowserImpl_Release,
/* IOleWindow */
IDesktopShellBrowserImpl_GetWindow,
IDesktopShellBrowserImpl_ContextSensitiveHelp,
/* IShellBrowser */
IDesktopShellBrowserImpl_InsertMenusSB,
IDesktopShellBrowserImpl_SetMenuSB,
IDesktopShellBrowserImpl_RemoveMenusSB,
IDesktopShellBrowserImpl_SetStatusTextSB,
IDesktopShellBrowserImpl_EnableModelessSB,
IDesktopShellBrowserImpl_TranslateAcceleratorSB,
IDesktopShellBrowserImpl_BrowseObject,
IDesktopShellBrowserImpl_GetViewStateStream,
IDesktopShellBrowserImpl_GetControlWindow,
IDesktopShellBrowserImpl_SendControlMsg,
IDesktopShellBrowserImpl_QueryActiveShellView,
IDesktopShellBrowserImpl_OnViewWindowActive,
IDesktopShellBrowserImpl_SetToolbarItems
};
/*
* ICommDlgBrowser
*/
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_ICommDlgBrowser_QueryInterface(IN OUT ICommDlgBrowser *iface,
IN REFIID riid,
OUT LPVOID *ppvObj)
{
IDesktopShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This);
return IDesktopShellBrowserImpl_QueryInterface(ShellBrowser,
riid,
ppvObj);
}
static ULONG STDMETHODCALLTYPE
IDesktopShellBrowserImpl_ICommDlgBrowser_Release(IN OUT ICommDlgBrowser *iface)
{
IDesktopShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This);
return IDesktopShellBrowserImpl_Release(ShellBrowser);
}
static ULONG STDMETHODCALLTYPE
IDesktopShellBrowserImpl_ICommDlgBrowser_AddRef(IN OUT ICommDlgBrowser *iface)
{
IDesktopShellBrowserImpl *This = impl_from_ICommDlgBrowser(iface);
IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This);
return IDesktopShellBrowserImpl_AddRef(ShellBrowser);
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand(IN OUT ICommDlgBrowser *iface,
IN OUT IShellView *ppshv)
{
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_ICommDlgBrowser_OnStateChange(IN OUT ICommDlgBrowser *iface,
IN OUT IShellView *ppshv,
IN ULONG uChange)
{
return S_OK;
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_ICommDlgBrowser_IncludeObject(IN OUT ICommDlgBrowser *iface,
IN OUT IShellView *ppshv,
IN LPCITEMIDLIST pidl)
{
return S_OK;
}
static const ICommDlgBrowserVtbl IDesktopShellBrowserImpl_ICommDlgBrowser_Vtbl =
{
/* IUnknown */
IDesktopShellBrowserImpl_ICommDlgBrowser_QueryInterface,
IDesktopShellBrowserImpl_ICommDlgBrowser_AddRef,
IDesktopShellBrowserImpl_ICommDlgBrowser_Release,
/* ICommDlgBrowser */
IDesktopShellBrowserImpl_ICommDlgBrowser_OnDefaultCommand,
IDesktopShellBrowserImpl_ICommDlgBrowser_OnStateChange,
IDesktopShellBrowserImpl_ICommDlgBrowser_IncludeObject
};
/*
* IServiceProvider
*/
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_IServiceProvider_QueryInterface(IN OUT IServiceProvider *iface,
IN REFIID riid,
OUT LPVOID *ppvObj)
{
IDesktopShellBrowserImpl *This = impl_from_IServiceProvider(iface);
IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This);
return IDesktopShellBrowserImpl_QueryInterface(ShellBrowser,
riid,
ppvObj);
}
static ULONG STDMETHODCALLTYPE
IDesktopShellBrowserImpl_IServiceProvider_Release(IN OUT IServiceProvider *iface)
{
IDesktopShellBrowserImpl *This = impl_from_IServiceProvider(iface);
IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This);
return IDesktopShellBrowserImpl_Release(ShellBrowser);
}
static ULONG STDMETHODCALLTYPE
IDesktopShellBrowserImpl_IServiceProvider_AddRef(IN OUT IServiceProvider *iface)
{
IDesktopShellBrowserImpl *This = impl_from_IServiceProvider(iface);
IShellBrowser *ShellBrowser = IShellBrowser_from_impl(This);
return IDesktopShellBrowserImpl_AddRef(ShellBrowser);
}
static HRESULT STDMETHODCALLTYPE
IDesktopShellBrowserImpl_IServiceProvider_QueryService(IN OUT IServiceProvider *iface,
IN REFGUID guidService,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -