mirror of
https://github.com/reactos/reactos.git
synced 2025-07-04 20:11:22 +00:00
small improvements for DesktopWindow
svn path=/trunk/; revision=5500
This commit is contained in:
parent
5bdce2b978
commit
749c3d1719
4 changed files with 45 additions and 48 deletions
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
|
|
||||||
static BOOL (WINAPI*SetShellWindow)(HWND);
|
static BOOL (WINAPI*SetShellWindow)(HWND);
|
||||||
|
static BOOL (WINAPI*SetShellWindowEx)(HWND, HWND);
|
||||||
|
|
||||||
|
|
||||||
BOOL IsAnyDesktopRunning()
|
BOOL IsAnyDesktopRunning()
|
||||||
|
@ -39,6 +40,7 @@ BOOL IsAnyDesktopRunning()
|
||||||
HINSTANCE shell32 = GetModuleHandle(TEXT("user32"));
|
HINSTANCE shell32 = GetModuleHandle(TEXT("user32"));
|
||||||
|
|
||||||
SetShellWindow = (BOOL(WINAPI*)(HWND)) GetProcAddress(shell32, "SetShellWindow");
|
SetShellWindow = (BOOL(WINAPI*)(HWND)) GetProcAddress(shell32, "SetShellWindow");
|
||||||
|
SetShellWindowEx = (BOOL(WINAPI*)(HWND,HWND)) GetProcAddress(shell32, "SetShellWindowEx");
|
||||||
|
|
||||||
return GetShellWindow() != 0;
|
return GetShellWindow() != 0;
|
||||||
}
|
}
|
||||||
|
@ -48,16 +50,10 @@ DesktopWindow::DesktopWindow(HWND hwnd)
|
||||||
: super(hwnd)
|
: super(hwnd)
|
||||||
{
|
{
|
||||||
_pShellView = NULL;
|
_pShellView = NULL;
|
||||||
|
|
||||||
if (SetShellWindow)
|
|
||||||
SetShellWindow(hwnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DesktopWindow::~DesktopWindow()
|
DesktopWindow::~DesktopWindow()
|
||||||
{
|
{
|
||||||
if (SetShellWindow)
|
|
||||||
SetShellWindow(0);
|
|
||||||
|
|
||||||
if (_pShellView)
|
if (_pShellView)
|
||||||
_pShellView->Release();
|
_pShellView->Release();
|
||||||
}
|
}
|
||||||
|
@ -102,6 +98,40 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||||
case WM_GETISHELLBROWSER:
|
case WM_GETISHELLBROWSER:
|
||||||
return (LRESULT)static_cast<IShellBrowser*>(this);
|
return (LRESULT)static_cast<IShellBrowser*>(this);
|
||||||
|
|
||||||
|
case WM_CREATE: {
|
||||||
|
HRESULT hr = Desktop()->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView);
|
||||||
|
|
||||||
|
HWND hWndListView = 0;
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
FOLDERSETTINGS fs;
|
||||||
|
|
||||||
|
fs.ViewMode = FWF_DESKTOP|FWF_TRANSPARENT|FWF_NOSUBFOLDERS|FWF_BESTFITWINDOW|FWF_ABBREVIATEDNAMES;
|
||||||
|
fs.fFlags = FVM_ICON;
|
||||||
|
|
||||||
|
RECT rect;
|
||||||
|
GetClientRect(_hwnd, &rect);
|
||||||
|
|
||||||
|
hr = _pShellView->CreateViewWindow(NULL, &fs, this, &rect, &hWndListView);
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
HWND hwndFolderView = ::GetNextWindow(hWndListView, GW_CHILD);
|
||||||
|
|
||||||
|
ShowWindow(hwndFolderView, SW_SHOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hWndListView && SetShellWindowEx)
|
||||||
|
SetShellWindowEx(_hwnd, hWndListView);
|
||||||
|
else if (SetShellWindow)
|
||||||
|
SetShellWindow(_hwnd);
|
||||||
|
break;}
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
if (SetShellWindow)
|
||||||
|
SetShellWindow(0);
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
break; // Over-ride close. We need to close desktop some other way.
|
break; // Over-ride close. We need to close desktop some other way.
|
||||||
|
|
||||||
|
@ -128,39 +158,7 @@ HWND create_desktop_window(HINSTANCE hInstance)
|
||||||
int width = GetSystemMetrics(SM_CXSCREEN);
|
int width = GetSystemMetrics(SM_CXSCREEN);
|
||||||
int height = GetSystemMetrics(SM_CYSCREEN);
|
int height = GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
|
||||||
HWND hwndDesktop = Window::Create(WINDOW_CREATOR(DesktopWindow),
|
return Window::Create(WINDOW_CREATOR(DesktopWindow),
|
||||||
0, (LPCTSTR)desktopClass, _T("Progman"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN,
|
0, (LPCTSTR)(int)desktopClass, _T("Progman"), WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN,
|
||||||
0, 0, width, height, 0);
|
0, 0, width, height, 0);
|
||||||
|
|
||||||
if (!hwndDesktop)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
|
||||||
ShellFolder folder;
|
|
||||||
|
|
||||||
IShellView* pShellView;
|
|
||||||
HRESULT hr = folder->CreateViewObject(hwndDesktop, IID_IShellView, (void**)&pShellView);
|
|
||||||
|
|
||||||
HWND hWndListView = 0;
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
FOLDERSETTINGS fs;
|
|
||||||
|
|
||||||
fs.ViewMode = 0;
|
|
||||||
fs.fFlags = FVM_ICON;
|
|
||||||
|
|
||||||
RECT rect = {0, 0, width, height};
|
|
||||||
|
|
||||||
DesktopWindow* shell_browser = static_cast<DesktopWindow*>(Window::get_window(hwndDesktop));
|
|
||||||
|
|
||||||
hr = pShellView->CreateViewWindow(NULL, &fs, shell_browser, &rect, &hWndListView);
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
HWND hwndFolderView = GetNextWindow(hWndListView, GW_CHILD);
|
|
||||||
|
|
||||||
ShowWindow(hwndFolderView, SW_SHOW);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return hwndDesktop;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,8 @@ struct DesktopWindow : public Window, public IShellBrowserImpl
|
||||||
{
|
{
|
||||||
typedef Window super;
|
typedef Window super;
|
||||||
|
|
||||||
DesktopWindow::DesktopWindow(HWND hwnd);
|
DesktopWindow(HWND hwnd);
|
||||||
|
~DesktopWindow();
|
||||||
DesktopWindow::~DesktopWindow();
|
|
||||||
|
|
||||||
STDMETHOD(GetWindow)(HWND* lphwnd)
|
STDMETHOD(GetWindow)(HWND* lphwnd)
|
||||||
{
|
{
|
||||||
|
@ -48,14 +47,14 @@ struct DesktopWindow : public Window, public IShellBrowserImpl
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHOD(QueryActiveShellView)(struct IShellView ** ppshv)
|
STDMETHOD(QueryActiveShellView)(IShellView** ppshv)
|
||||||
{
|
{
|
||||||
_pShellView->AddRef();
|
_pShellView->AddRef();
|
||||||
*ppshv = _pShellView;
|
*ppshv = _pShellView;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHOD(GetControlWindow)(UINT id, HWND * lphwnd)
|
STDMETHOD(GetControlWindow)(UINT id, HWND* lphwnd)
|
||||||
{
|
{
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,8 +359,8 @@ void ShellBrowserChild::OnTreeItemSelected(int idCtrl, LPNMTREEVIEW pnmtv)
|
||||||
if (pLastShellView)
|
if (pLastShellView)
|
||||||
pLastShellView->GetCurrentInfo(&fs);
|
pLastShellView->GetCurrentInfo(&fs);
|
||||||
else {
|
else {
|
||||||
fs.fFlags = FVM_DETAILS;
|
|
||||||
fs.ViewMode = FWF_SNAPTOGRID;
|
fs.ViewMode = FWF_SNAPTOGRID;
|
||||||
|
fs.fFlags = FVM_DETAILS;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT hr = folder->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView);
|
HRESULT hr = folder->CreateViewObject(_hwnd, IID_IShellView, (void**)&_pShellView);
|
||||||
|
|
|
@ -57,14 +57,14 @@ struct ShellBrowserChild : public ChildWindow, public IShellBrowserImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
//IShellBrowser
|
//IShellBrowser
|
||||||
STDMETHOD(QueryActiveShellView)(struct IShellView ** ppshv)
|
STDMETHOD(QueryActiveShellView)(IShellView** ppshv)
|
||||||
{
|
{
|
||||||
_pShellView->AddRef();
|
_pShellView->AddRef();
|
||||||
*ppshv = _pShellView;
|
*ppshv = _pShellView;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STDMETHOD(GetControlWindow)(UINT id, HWND * lphwnd)
|
STDMETHOD(GetControlWindow)(UINT id, HWND* lphwnd)
|
||||||
{
|
{
|
||||||
if (!lphwnd)
|
if (!lphwnd)
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue