mirror of
https://github.com/reactos/reactos.git
synced 2024-09-10 12:54:51 +00:00
![David Quintana](/assets/img/avatar_default.png)
* Make use of the CToolbar<T> class to implement a CTaskToolbar. * Change the CTaskSwitchWnd class to use CTaskToolbar instead of managing the HWND directly. * Silence logspam in CTrayBandSite. * Fix CNotifyToolbar to properly. * Move the call to SetMetrics to be called only on initialization, instead of every time an icon changes. * Make the start button a CContainedWindowT instead of a raw HWND. TODO: Make a CStartButton class to manage it. [include/reactos/rosctrls.h] * Some improvements needed by the taskbar. svn path=/branches/shell-experiments/; revision=65274
240 lines
5.8 KiB
C++
240 lines
5.8 KiB
C++
/*
|
|
* ReactOS Explorer
|
|
*
|
|
* Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include "precomp.h"
|
|
#include <shlwapi_undoc.h>
|
|
|
|
DWORD WINAPI _WinList_Init(void);
|
|
void WINAPI _ShellDDEInit(BOOL bInit);
|
|
|
|
HINSTANCE hExplorerInstance;
|
|
HMODULE hUser32;
|
|
HANDLE hProcessHeap;
|
|
HKEY hkExplorer = NULL;
|
|
DRAWCAPTEMP DrawCapTemp = NULL;
|
|
|
|
class CExplorerModule : public CComModule
|
|
{
|
|
public:
|
|
};
|
|
|
|
BEGIN_OBJECT_MAP(ObjectMap)
|
|
END_OBJECT_MAP()
|
|
|
|
CExplorerModule gModule;
|
|
CAtlWinModule gWinModule;
|
|
|
|
void *operator new (size_t, void *buf)
|
|
{
|
|
return buf;
|
|
}
|
|
|
|
static VOID InitializeAtlModule(HINSTANCE hInstance, BOOL bInitialize)
|
|
{
|
|
if (bInitialize)
|
|
{
|
|
/* HACK - the global constructors don't run, so I placement new them here */
|
|
new (&gModule) CExplorerModule;
|
|
new (&gWinModule) CAtlWinModule;
|
|
new (&_AtlBaseModule) CAtlBaseModule;
|
|
new (&_AtlComModule) CAtlComModule;
|
|
|
|
gModule.Init(ObjectMap, hInstance, NULL);
|
|
}
|
|
else
|
|
{
|
|
gModule.Term();
|
|
}
|
|
}
|
|
|
|
#if !WIN7_COMPAT_MODE
|
|
static BOOL
|
|
SetShellReadyEvent(IN LPCTSTR lpEventName)
|
|
{
|
|
HANDLE hEvent;
|
|
|
|
hEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, lpEventName);
|
|
if (hEvent != NULL)
|
|
{
|
|
SetEvent(hEvent);
|
|
|
|
CloseHandle(hEvent);
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
static VOID
|
|
HideMinimizedWindows(IN BOOL bHide)
|
|
{
|
|
MINIMIZEDMETRICS mm;
|
|
|
|
mm.cbSize = sizeof(mm);
|
|
if (!SystemParametersInfo(SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0))
|
|
{
|
|
ERR("SystemParametersInfo failed with %lu\n", GetLastError());
|
|
return;
|
|
}
|
|
if (bHide)
|
|
mm.iArrange |= ARW_HIDE;
|
|
else
|
|
mm.iArrange &= ~ARW_HIDE;
|
|
if (!SystemParametersInfo(SPI_SETMINIMIZEDMETRICS, sizeof(mm), &mm, 0))
|
|
ERR("SystemParametersInfo failed with %lu\n", GetLastError());
|
|
}
|
|
|
|
static INT
|
|
StartWithCommandLine(IN HINSTANCE hInstance)
|
|
{
|
|
BOOL b = FALSE;
|
|
EXPLORER_CMDLINE_PARSE_RESULTS parseResults = { 0 };
|
|
|
|
if (SHExplorerParseCmdLine(&parseResults))
|
|
b = SHCreateFromDesktop(&parseResults);
|
|
|
|
if (parseResults.strPath)
|
|
SHFree(parseResults.strPath);
|
|
|
|
if (parseResults.pidlPath)
|
|
ILFree(parseResults.pidlPath);
|
|
|
|
if (parseResults.pidlRoot)
|
|
ILFree(parseResults.pidlRoot);
|
|
|
|
return b;
|
|
}
|
|
#endif
|
|
|
|
static INT
|
|
StartWithDesktop(IN HINSTANCE hInstance)
|
|
{
|
|
InitializeAtlModule(hInstance, TRUE);
|
|
|
|
if (RegOpenKey(HKEY_CURRENT_USER,
|
|
L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer",
|
|
&hkExplorer) != ERROR_SUCCESS)
|
|
{
|
|
WCHAR Message[256];
|
|
LoadString(hInstance, IDS_STARTUP_ERROR, Message, 256);
|
|
MessageBox(NULL, Message, NULL, MB_ICONERROR);
|
|
return 1;
|
|
}
|
|
|
|
hExplorerInstance = hInstance;
|
|
hProcessHeap = GetProcessHeap();
|
|
LoadAdvancedSettings();
|
|
|
|
hUser32 = GetModuleHandle(TEXT("USER32.DLL"));
|
|
if (hUser32 != NULL)
|
|
{
|
|
DrawCapTemp = (DRAWCAPTEMP) GetProcAddress(hUser32, PROC_NAME_DRAWCAPTIONTEMP);
|
|
}
|
|
|
|
InitCommonControls();
|
|
OleInitialize(NULL);
|
|
|
|
#if !WIN7_COMPAT_MODE
|
|
ProcessStartupItems();
|
|
|
|
/* Initialize shell dde support */
|
|
_ShellDDEInit(TRUE);
|
|
#endif
|
|
|
|
/* Initialize shell icons */
|
|
FileIconInit(TRUE);
|
|
|
|
/* Initialize CLSID_ShellWindows class */
|
|
_WinList_Init();
|
|
|
|
CComPtr<ITrayWindow> Tray;
|
|
CreateTrayWindow(&Tray);
|
|
|
|
#if !WIN7_COMPAT_MODE
|
|
/* This not only hides the minimized window captions in the bottom
|
|
left screen corner, but is also needed in order to receive
|
|
HSHELL_* notification messages (which are required for taskbar
|
|
buttons to work right) */
|
|
HideMinimizedWindows(TRUE);
|
|
|
|
HANDLE hShellDesktop = NULL;
|
|
if (Tray != NULL)
|
|
hShellDesktop = DesktopCreateWindow(Tray);
|
|
|
|
/* WinXP: Notify msgina to hide the welcome screen */
|
|
if (!SetShellReadyEvent(TEXT("msgina: ShellReadyEvent")))
|
|
SetShellReadyEvent(TEXT("Global\\msgina: ShellReadyEvent"));
|
|
#endif
|
|
|
|
if (Tray != NULL)
|
|
{
|
|
#if !WIN7_COMPAT_MODE
|
|
RegisterHotKey(NULL, IDHK_RUN, MOD_WIN, 'R');
|
|
#endif
|
|
TrayMessageLoop(Tray);
|
|
#if !WIN7_COMPAT_MODE
|
|
HideMinimizedWindows(FALSE);
|
|
#endif
|
|
}
|
|
|
|
#if !WIN7_COMPAT_MODE
|
|
if (hShellDesktop != NULL)
|
|
DesktopDestroyShellWindow(hShellDesktop);
|
|
#endif
|
|
|
|
OleUninitialize();
|
|
|
|
RegCloseKey(hkExplorer);
|
|
hkExplorer = NULL;
|
|
|
|
InitializeAtlModule(hInstance, FALSE);
|
|
|
|
return 0;
|
|
}
|
|
|
|
INT WINAPI
|
|
_tWinMain(IN HINSTANCE hInstance,
|
|
IN HINSTANCE hPrevInstance,
|
|
IN LPTSTR lpCmdLine,
|
|
IN INT nCmdShow)
|
|
{
|
|
#if !WIN7_COMPAT_MODE
|
|
BOOL CreateShellDesktop = FALSE;
|
|
|
|
TRACE("Explorer starting... Commandline: %S\n", lpCmdLine);
|
|
|
|
/*
|
|
* Set our shutdown parameters: we want to shutdown the very last,
|
|
* but before any TaskMgr instance (which has a shutdown level of 1).
|
|
*/
|
|
SetProcessShutdownParameters(2, 0);
|
|
|
|
if (GetShellWindow() == NULL)
|
|
CreateShellDesktop = TRUE;
|
|
|
|
if (!CreateShellDesktop)
|
|
{
|
|
return StartWithCommandLine(hInstance);
|
|
}
|
|
#endif
|
|
|
|
return StartWithDesktop(hInstance);
|
|
}
|