merge ROS Shell without integrated explorer part into trunk
[reactos.git] / reactos / subsys / system / explorer / explorer.cpp
index e2e0b94..435fb23 100644 (file)
@@ -56,11 +56,15 @@ ExplorerGlobals g_Globals;
 ExplorerGlobals::ExplorerGlobals()
 {
        _hInstance = 0;
-       _hframeClass = 0;
        _cfStrFName = 0;
+
+#ifndef ROSSHELL
+       _hframeClass = 0;
        _hMainWnd = 0;
-       _prescan_nodes = false;
        _desktop_mode = false;
+       _prescan_nodes = false;
+#endif
+
        _log = NULL;
 #ifndef __MINGW32__    // SHRestricted() missing in MinGW (as of 29.10.2003)
        _SHRestricted = 0;
@@ -528,6 +532,8 @@ ResBitmap::ResBitmap(UINT nid)
 }
 
 
+#ifndef ROSSHELL
+
 void explorer_show_frame(int cmdshow, LPTSTR lpCmdLine)
 {
        if (g_Globals._hMainWnd) {
@@ -553,6 +559,18 @@ void explorer_show_frame(int cmdshow, LPTSTR lpCmdLine)
        MainFrameBase::Create(lpCmdLine, mdi, cmdshow);
 }
 
+#else
+
+void explorer_show_frame(int cmdshow, LPTSTR lpCmdLine)
+{
+       if (!lpCmdLine)
+               lpCmdLine = TEXT("explorer.exe");
+
+       launch_file(GetDesktopWindow(), lpCmdLine, cmdshow);
+}
+
+#endif
+
 
 PopupMenu::PopupMenu(UINT nid)
 {
@@ -637,6 +655,7 @@ static void InitInstance(HINSTANCE hInstance)
 
        setlocale(LC_COLLATE, "");      // set collating rules to local settings for compareName
 
+#ifndef ROSSHELL
         // register frame window class
        g_Globals._hframeClass = IconWindowClass(CLASSNAME_FRAME,IDI_EXPLORER);
 
@@ -645,6 +664,7 @@ static void InitInstance(HINSTANCE hInstance)
 
         // register tree window class
        WindowClass(CLASSNAME_WINEFILETREE, CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW).Register();
+#endif
 
        g_Globals._cfStrFName = RegisterClipboardFormat(CFSTR_FILENAME);
 }
@@ -664,6 +684,7 @@ int explorer_main(HINSTANCE hInstance, LPTSTR lpCmdLine, int cmdshow)
                return -1;
        }
 
+#ifndef ROSSHELL
        if (cmdshow != SW_HIDE) {
 /*     // don't maximize if being called from the ROS desktop
                if (cmdshow == SW_SHOWNORMAL)
@@ -673,6 +694,7 @@ int explorer_main(HINSTANCE hInstance, LPTSTR lpCmdLine, int cmdshow)
 
                explorer_show_frame(cmdshow, lpCmdLine);
        }
+#endif
 
        return Window::MessageLoop();
 }
@@ -798,12 +820,14 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
         // If there is given the command line option "-desktop", create desktop window anyways
        if (_tcsstr(lpCmdLine,TEXT("-desktop")))
                startup_desktop = TRUE;
+#ifndef ROSSHELL
        else if (_tcsstr(lpCmdLine,TEXT("-nodesktop")))
                startup_desktop = FALSE;
 
         // Don't display cabinet window in desktop mode
        if (startup_desktop && !_tcsstr(lpCmdLine,TEXT("-explorer")))
                nShowCmd = SW_HIDE;
+#endif
 
        if (_tcsstr(lpCmdLine,TEXT("-noautostart")))
                autostart = false;
@@ -832,6 +856,11 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
                if (!SetShellReadyEvent(TEXT("msgina: ShellReadyEvent")))
                        SetShellReadyEvent(TEXT("Global\\msgina: ShellReadyEvent"));
        }
+#ifdef ROSSHELL
+       else
+               return 0;       // no shell to launch, so exit immediatelly
+#endif
+
 
        if (!any_desktop_running) {
                 // launch the shell DDE server
@@ -882,9 +911,6 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
 #endif
        }
 
-       if (g_Globals._hwndDesktop)
-               g_Globals._desktop_mode = true;
-
        Thread* pSSOThread = NULL;
 
        if (startup_desktop) {
@@ -899,11 +925,17 @@ int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdL
                startup(2, argv);
        }
 
+#ifndef ROSSHELL
+       if (g_Globals._hwndDesktop)
+               g_Globals._desktop_mode = true;
+
        /**TODO fix command line handling */
        if (*lpCmdLine=='"' && lpCmdLine[_tcslen(lpCmdLine)-1]=='"') {
                ++lpCmdLine;
                lpCmdLine[_tcslen(lpCmdLine)-1] = '\0';
        }
+#endif
+
 
        int ret = explorer_main(hInstance, lpCmdLine, nShowCmd);