[CONSRV]
[reactos.git] / reactos / win32ss / user / winsrv / consrv / frontends / gui / guiterm.c
index a974e9b..8587d98 100644 (file)
@@ -12,7 +12,6 @@
 /* INCLUDES *******************************************************************/
 
 #define COBJMACROS
-#define NONAMELESSUNION
 
 #include "consrv.h"
 #include "include/conio.h"
@@ -45,7 +44,7 @@
 
 
 /* Not defined in any header file */
-extern VOID WINAPI PrivateCsrssManualGuiCheck(LONG Check);
+extern VOID NTAPI PrivateCsrssManualGuiCheck(LONG Check);
 // See winsrv/usersrv/init.c line 234
 
 
@@ -64,16 +63,18 @@ typedef struct _GUI_INIT_INFO
 #define GWLP_CONSOLE_LEADER_PID 0
 #define GWLP_CONSOLE_LEADER_TID 4
 
-#define SetConsoleWndConsoleLeaderCID(GuiData)  \
-do {                                            \
-    PCONSOLE_PROCESS_DATA ProcessData;          \
-    CLIENT_ID ConsoleLeaderCID;                 \
+#define SetConsoleWndConsoleLeaderCID(GuiData)                              \
+do {                                                                        \
+    PCONSOLE_PROCESS_DATA ProcessData;                                      \
+    CLIENT_ID ConsoleLeaderCID;                                             \
     ProcessData = CONTAINING_RECORD((GuiData)->Console->ProcessList.Blink,  \
                                     CONSOLE_PROCESS_DATA,                   \
                                     ConsoleLink);                           \
     ConsoleLeaderCID = ProcessData->Process->ClientId;                      \
-    SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_PID, (LONG_PTR)(ConsoleLeaderCID.UniqueProcess));  \
-    SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_TID, (LONG_PTR)(ConsoleLeaderCID.UniqueThread ));  \
+    SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_PID,          \
+                      (LONG_PTR)(ConsoleLeaderCID.UniqueProcess));          \
+    SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_TID,          \
+                      (LONG_PTR)(ConsoleLeaderCID.UniqueThread ));          \
 } while (0)
 /**************************************************************/
 
@@ -246,7 +247,7 @@ static VOID
 GuiConsolePaste(PGUI_CONSOLE_DATA GuiData);
 static VOID
 GuiConsoleUpdateSelection(PCONSOLE Console, PCOORD coord);
-static VOID WINAPI
+static VOID NTAPI
 GuiDrawRegion(IN OUT PFRONTEND This, SMALL_RECT* Region);
 static VOID
 GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData);
@@ -264,7 +265,8 @@ GuiConsoleHandleSysMenuCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM
         Ret = FALSE;
         goto Quit;
     }
-    ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
+    // ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
+    ActiveBuffer = GuiData->ActiveBuffer;
 
     /*
      * In case the selected menu item belongs to the user-reserved menu id range,
@@ -314,10 +316,34 @@ GuiConsoleHandleSysMenuCommand(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM
             LPWSTR WindowTitle = NULL;
             SIZE_T Length = 0;
 
+            /*
+             * The selection area extends to the whole screen buffer's width.
+             */
             Console->Selection.dwSelectionAnchor.X = 0;
             Console->Selection.dwSelectionAnchor.Y = 0;
-            Console->dwSelectionCursor.X = ActiveBuffer->ViewSize.X - 1;
-            Console->dwSelectionCursor.Y = ActiveBuffer->ViewSize.Y - 1;
+            Console->dwSelectionCursor.X = ActiveBuffer->ScreenBufferSize.X - 1;
+
+            /*
+             * Determine whether the selection must extend to just some part
+             * (for text-mode screen buffers) or to all of the screen buffer's
+             * height (for graphics ones).
+             */
+            if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
+            {
+                /*
+                 * We select all the characters from the first line
+                 * to the line where the cursor is positioned.
+                 */
+                Console->dwSelectionCursor.Y = ActiveBuffer->CursorPosition.Y;
+            }
+            else /* if (GetType(ActiveBuffer) == GRAPHICS_BUFFER) */
+            {
+                /*
+                 * We select all the screen buffer area.
+                 */
+                Console->dwSelectionCursor.Y = ActiveBuffer->ScreenBufferSize.Y - 1;
+            }
+
             Console->Selection.dwFlags |= CONSOLE_SELECTION_IN_PROGRESS | CONSOLE_MOUSE_SELECTION;
             GuiConsoleUpdateSelection(Console, &Console->dwSelectionCursor);
 
@@ -388,8 +414,8 @@ GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData)
 static VOID
 GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData)
 {
-    PCONSOLE Console = GuiData->Console;
-    PCONSOLE_SCREEN_BUFFER Buff = ConDrvGetActiveScreenBuffer(Console);
+    // PCONSOLE Console = GuiData->Console;
+    PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
     SCROLLINFO sInfo;
 
     DWORD Width, Height;
@@ -441,52 +467,153 @@ GuiConsoleResizeWindow(PGUI_CONSOLE_DATA GuiData)
     // to: InvalidateRect(GuiData->hWindow, NULL, TRUE);
 }
 
+
+
+static BOOL
+EnterFullScreen(PGUI_CONSOLE_DATA GuiData)
+{
+    DEVMODEW DevMode;
+
+    ZeroMemory(&DevMode, sizeof(DevMode));
+    DevMode.dmSize = sizeof(DevMode);
+
+    // DevMode.dmDisplayFixedOutput = DMDFO_CENTER; // DMDFO_STRETCH // DMDFO_DEFAULT
+    // DevMode.dmDisplayFlags = DMDISPLAYFLAGS_TEXTMODE;
+    DevMode.dmPelsWidth  = 640; // GuiData->ActiveBuffer->ViewSize.X * GuiData->CharWidth;
+    DevMode.dmPelsHeight = 480; // GuiData->ActiveBuffer->ViewSize.Y * GuiData->CharHeight;
+    // DevMode.dmBitsPerPel = 32;
+    DevMode.dmFields     = /* DM_DISPLAYFIXEDOUTPUT | DM_DISPLAYFLAGS | DM_BITSPERPEL | */ DM_PELSWIDTH | DM_PELSHEIGHT;
+
+    return (ChangeDisplaySettingsW(&DevMode, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL);
+}
+
+static BOOL
+LeaveFullScreen(PGUI_CONSOLE_DATA GuiData)
+{
+    return (ChangeDisplaySettingsW(NULL, CDS_RESET) == DISP_CHANGE_SUCCESSFUL);
+}
+
 static VOID
-GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData)
+GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam);
+
+VOID
+SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen)
 {
     PCONSOLE Console = GuiData->Console;
-    // DEVMODE dmScreenSettings;
 
-    if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+    /*
+     * See:
+     * http://stackoverflow.com/questions/2382464/win32-full-screen-and-hiding-taskbar
+     * http://stackoverflow.com/questions/3549148/fullscreen-management-with-winapi
+     * http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx
+     * http://blogs.msdn.com/b/oldnewthing/archive/2005/05/05/414910.aspx
+     * http://stackoverflow.com/questions/1400654/how-do-i-put-my-opengl-app-into-fullscreen-mode
+     * http://nehe.gamedev.net/tutorial/creating_an_opengl_window_win32/13001/
+     * http://www.reocities.com/pcgpe/dibs.html
+     */
 
-    /* Switch to full-screen or to windowed mode */
-    GuiData->GuiInfo.FullScreen = !GuiData->GuiInfo.FullScreen;
-    DPRINT1("GuiConsoleSwitchFullScreen - Switch to %s ...\n",
-            (GuiData->GuiInfo.FullScreen ? "full-screen" : "windowed mode"));
-
-    // TODO: Change window appearance.
-    // See:
-    // http://stackoverflow.com/questions/2382464/win32-full-screen-and-hiding-taskbar
-    // http://stackoverflow.com/questions/3549148/fullscreen-management-with-winapi
-    // http://blogs.msdn.com/b/oldnewthing/archive/2010/04/12/9994016.aspx
-    // http://stackoverflow.com/questions/1400654/how-do-i-put-my-opengl-app-into-fullscreen-mode
-    // http://nehe.gamedev.net/tutorial/creating_an_opengl_window_win32/13001/
-#if 0
-    if (GuiData->GuiInfo.FullScreen)
+    if (FullScreen)
     {
-        memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
-        dmScreenSettings.dmSize       = sizeof(dmScreenSettings);
-        dmScreenSettings.dmDisplayFixedOutput = DMDFO_CENTER; // DMDFO_STRETCH // DMDFO_DEFAULT
-        dmScreenSettings.dmPelsWidth  = 640; // Console->ActiveBuffer->ViewSize.X * GuiData->CharWidth;
-        dmScreenSettings.dmPelsHeight = 480; // Console->ActiveBuffer->ViewSize.Y * GuiData->CharHeight;
-        dmScreenSettings.dmBitsPerPel = 32;
-        dmScreenSettings.dmFields     = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
-        ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
+        SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+
+        /* Switch to full screen */
+        if (EnterFullScreen(GuiData))
+        {
+            /* Save the new state */
+            GuiData->GuiInfo.FullScreen = TRUE;
+            Console->FixedSize = TRUE;
+
+            GuiData->ActiveBuffer->OldViewSize = GuiData->ActiveBuffer->ViewSize;
+            // GuiData->ActiveBuffer->OldScreenBufferSize = GuiData->ActiveBuffer->ScreenBufferSize;
+
+            /* Save the old window styles */
+            GuiData->WndStyle   = GetWindowLongPtr(GuiData->hWindow, GWL_STYLE  );
+            GuiData->WndStyleEx = GetWindowLongPtr(GuiData->hWindow, GWL_EXSTYLE);
+
+            /* Change the window styles */
+            SetWindowLongPtr(GuiData->hWindow, GWL_STYLE,
+                             WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
+            SetWindowLongPtr(GuiData->hWindow, GWL_EXSTYLE,
+                             WS_EX_APPWINDOW);
+
+            /* Reposition the window to the upper-left corner */
+            SetWindowPos(GuiData->hWindow,
+                         HWND_TOPMOST,
+                         0, 0,
+                         0, 0,
+                         SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
+            /* Make it the foreground window */
+            SetForegroundWindow(GuiData->hWindow);
+            /* Resize it */
+            // GuiConsoleResizeWindow(GuiData);
+            GuiConsoleResize(GuiData, SIZE_RESTORED, MAKELPARAM(640, 480));
+
+            PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
+        }
+        else
+        {
+            PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
+        }
     }
     else
     {
+        SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+
+        /* Restore windowing mode */
+        if (LeaveFullScreen(GuiData))
+        {
+            /* Save the new state */
+            GuiData->GuiInfo.FullScreen = FALSE;
+            Console->FixedSize = FALSE;
+
+            /*
+             * Restore possible saved dimensions
+             * of the active screen buffer view.
+             */
+            GuiData->ActiveBuffer->ViewSize = GuiData->ActiveBuffer->OldViewSize;
+            // GuiData->ActiveBuffer->ScreenBufferSize = GuiData->ActiveBuffer->OldScreenBufferSize;
+
+            /* Restore the window styles */
+            SetWindowLongPtr(GuiData->hWindow, GWL_STYLE,
+                             GuiData->WndStyle);
+            SetWindowLongPtr(GuiData->hWindow, GWL_EXSTYLE,
+                             GuiData->WndStyleEx);
+
+            /* Resize it */
+            GuiConsoleResizeWindow(GuiData);
+
+            // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
+        }
+        PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
     }
-#endif
+}
+
+static VOID
+GuiConsoleSwitchFullScreen(PGUI_CONSOLE_DATA GuiData)
+{
+    PCONSOLE Console = GuiData->Console;
+    BOOL FullScreen;
+
+    if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
+
+    /* Switch to full-screen or to windowed mode */
+    FullScreen = !GuiData->GuiInfo.FullScreen;
+    DPRINT1("GuiConsoleSwitchFullScreen - Switch to %s ...\n",
+            (FullScreen ? "full-screen" : "windowed mode"));
+
+    SwitchFullScreen(GuiData, FullScreen);
 
     LeaveCriticalSection(&Console->Lock);
 }
 
+
+
 static BOOL
 GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
 {
     PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)Create->lpCreateParams;
     PCONSOLE Console;
-    HDC Dc;
+    HDC hDC;
     HFONT OldFont;
     TEXTMETRICW Metrics;
     SIZE CharSize;
@@ -525,8 +652,8 @@ GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
         SetEvent(GuiData->hGuiInitEvent);
         return FALSE;
     }
-    Dc = GetDC(GuiData->hWindow);
-    if (NULL == Dc)
+    hDC = GetDC(GuiData->hWindow);
+    if (NULL == hDC)
     {
         DPRINT1("GuiConsoleNcCreate: GetDC failed\n");
         DeleteObject(GuiData->Font);
@@ -534,21 +661,21 @@ GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
         SetEvent(GuiData->hGuiInitEvent);
         return FALSE;
     }
-    OldFont = SelectObject(Dc, GuiData->Font);
+    OldFont = SelectObject(hDC, GuiData->Font);
     if (NULL == OldFont)
     {
         DPRINT1("GuiConsoleNcCreate: SelectObject failed\n");
-        ReleaseDC(GuiData->hWindow, Dc);
+        ReleaseDC(GuiData->hWindow, hDC);
         DeleteObject(GuiData->Font);
         GuiData->hWindow = NULL;
         SetEvent(GuiData->hGuiInitEvent);
         return FALSE;
     }
-    if (!GetTextMetricsW(Dc, &Metrics))
+    if (!GetTextMetricsW(hDC, &Metrics))
     {
         DPRINT1("GuiConsoleNcCreate: GetTextMetrics failed\n");
-        SelectObject(Dc, OldFont);
-        ReleaseDC(GuiData->hWindow, Dc);
+        SelectObject(hDC, OldFont);
+        ReleaseDC(GuiData->hWindow, hDC);
         DeleteObject(GuiData->Font);
         GuiData->hWindow = NULL;
         SetEvent(GuiData->hGuiInitEvent);
@@ -558,12 +685,12 @@ GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
     GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading;
 
     /* Measure real char width more precisely if possible. */
-    if (GetTextExtentPoint32W(Dc, L"R", 1, &CharSize))
+    if (GetTextExtentPoint32W(hDC, L"R", 1, &CharSize))
         GuiData->CharWidth = CharSize.cx;
 
-    SelectObject(Dc, OldFont);
+    SelectObject(hDC, OldFont);
 
-    ReleaseDC(GuiData->hWindow, Dc);
+    ReleaseDC(GuiData->hWindow, hDC);
 
     // FIXME: Keep these instructions here ? ///////////////////////////////////
     Console->ActiveBuffer->CursorBlinkOn = TRUE;
@@ -584,8 +711,8 @@ GuiConsoleHandleNcCreate(HWND hWnd, LPCREATESTRUCTW Create)
 static VOID
 SmallRectToRect(PGUI_CONSOLE_DATA GuiData, PRECT Rect, PSMALL_RECT SmallRect)
 {
-    PCONSOLE Console = GuiData->Console;
-    PCONSOLE_SCREEN_BUFFER Buffer = ConDrvGetActiveScreenBuffer(Console);
+    // PCONSOLE Console = GuiData->Console;
+    PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
     UINT WidthUnit, HeightUnit;
 
     GetScreenBufferSizeUnits(Buffer, GuiData, &WidthUnit, &HeightUnit);
@@ -683,7 +810,8 @@ GuiConsoleHandlePaint(PGUI_CONSOLE_DATA GuiData)
         Success = FALSE;
         goto Quit;
     }
-    ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
+    // ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
+    ActiveBuffer = GuiData->ActiveBuffer;
 
     hDC = BeginPaint(GuiData->hWindow, &ps);
     if (hDC != NULL &&
@@ -764,7 +892,8 @@ GuiConsoleHandleKey(PGUI_CONSOLE_DATA GuiData, UINT msg, WPARAM wParam, LPARAM l
 
     if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
 
-    ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
+    // ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
+    ActiveBuffer = GuiData->ActiveBuffer;
 
     if (Console->Selection.dwFlags & CONSOLE_SELECTION_IN_PROGRESS)
     {
@@ -936,7 +1065,7 @@ GuiConsoleHandleTimer(PGUI_CONSOLE_DATA GuiData)
 
     if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
 
-    Buff = ConDrvGetActiveScreenBuffer(Console);
+    Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
 
     if (GetType(Buff) == TEXTMODE_BUFFER)
     {
@@ -1059,8 +1188,8 @@ GuiConsoleHandleNcDestroy(HWND hWnd)
 static COORD
 PointToCoord(PGUI_CONSOLE_DATA GuiData, LPARAM lParam)
 {
-    PCONSOLE Console = GuiData->Console;
-    PCONSOLE_SCREEN_BUFFER Buffer = ConDrvGetActiveScreenBuffer(Console);
+    // PCONSOLE Console = GuiData->Console;
+    PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
     COORD Coord;
     UINT  WidthUnit, HeightUnit;
 
@@ -1339,7 +1468,7 @@ GuiConsoleCopy(PGUI_CONSOLE_DATA GuiData)
     if (OpenClipboard(GuiData->hWindow) == TRUE)
     {
         PCONSOLE Console = GuiData->Console;
-        PCONSOLE_SCREEN_BUFFER Buffer = ConDrvGetActiveScreenBuffer(Console);
+        PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
 
         if (GetType(Buffer) == TEXTMODE_BUFFER)
         {
@@ -1366,8 +1495,8 @@ GuiConsolePaste(PGUI_CONSOLE_DATA GuiData)
 {
     if (OpenClipboard(GuiData->hWindow) == TRUE)
     {
-        PCONSOLE Console = GuiData->Console;
-        PCONSOLE_SCREEN_BUFFER Buffer = ConDrvGetActiveScreenBuffer(Console);
+        // PCONSOLE Console = GuiData->Console;
+        PCONSOLE_SCREEN_BUFFER Buffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
 
         if (GetType(Buffer) == TEXTMODE_BUFFER)
         {
@@ -1392,7 +1521,8 @@ GuiConsoleGetMinMaxInfo(PGUI_CONSOLE_DATA GuiData, PMINMAXINFO minMaxInfo)
 
     if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return;
 
-    ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
+    // ActiveBuffer = ConDrvGetActiveScreenBuffer(Console);
+    ActiveBuffer = GuiData->ActiveBuffer;
 
     GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
 
@@ -1424,7 +1554,7 @@ GuiConsoleResize(PGUI_CONSOLE_DATA GuiData, WPARAM wParam, LPARAM lParam)
     if ((GuiData->WindowSizeLock == FALSE) &&
         (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED || wParam == SIZE_MINIMIZED))
     {
-        PCONSOLE_SCREEN_BUFFER Buff = ConDrvGetActiveScreenBuffer(Console);
+        PCONSOLE_SCREEN_BUFFER Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
         DWORD windx, windy, charx, chary;
         UINT  WidthUnit, HeightUnit;
 
@@ -1518,7 +1648,7 @@ GuiConsoleHandleScroll(PGUI_CONSOLE_DATA GuiData, UINT uMsg, WPARAM wParam)
 
     if (!ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE)) return 0;
 
-    Buff = ConDrvGetActiveScreenBuffer(Console);
+    Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(Console);
 
     if (uMsg == WM_HSCROLL)
     {
@@ -1643,6 +1773,9 @@ GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
     GuiData = GuiGetGuiData(hWnd);
     if (GuiData == NULL) return DefWindowProcW(hWnd, msg, wParam, lParam);
 
+    // TEMPORARY HACK until all of the functions can deal with a NULL GuiData->ActiveBuffer ...
+    if (GuiData->ActiveBuffer == NULL) return DefWindowProcW(hWnd, msg, wParam, lParam);
+
     /*
      * Just retrieve a pointer to the console in case somebody needs it.
      * It is not NULL because it was checked in GuiGetGuiData.
@@ -1655,7 +1788,31 @@ GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
     {
         case WM_ACTIVATE:
         {
-            if (LOWORD(wParam) == WA_CLICKACTIVE) GuiData->IgnoreNextMouseSignal = TRUE;
+            WORD ActivationState = LOWORD(wParam);
+
+            if ( ActivationState == WA_ACTIVE ||
+                 ActivationState == WA_CLICKACTIVE )
+            {
+                if (GuiData->GuiInfo.FullScreen)
+                {
+                    EnterFullScreen(GuiData);
+                    // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
+                    // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_RESTORE, 0);
+                }
+            }
+            else // if (ActivationState == WA_INACTIVE)
+            {
+                if (GuiData->GuiInfo.FullScreen)
+                {
+                    SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+                    LeaveFullScreen(GuiData);
+                    // // PostMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+                    // SendMessageW(GuiData->hWindow, WM_SYSCOMMAND, SC_MINIMIZE, 0);
+                }
+            }
+
+            if (ActivationState == WA_CLICKACTIVE) GuiData->IgnoreNextMouseSignal = TRUE;
+
             break;
         }
 
@@ -1667,6 +1824,52 @@ GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
             GuiConsoleHandlePaint(GuiData);
             break;
 
+        case WM_PALETTECHANGED:
+        {
+            PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console);
+
+            DPRINT1("WM_PALETTECHANGED called\n");
+
+            /*
+             * Protects against infinite loops:
+             * "... A window that receives this message must not realize
+             * its palette, unless it determines that wParam does not contain
+             * its own window handle." (WM_PALETTECHANGED description - MSDN)
+             *
+             * This message is sent to all windows, including the one that
+             * changed the system palette and caused this message to be sent.
+             * The wParam of this message contains the handle of the window
+             * that caused the system palette to change. To avoid an infinite
+             * loop, care must be taken to check that the wParam of this message
+             * does not match the window's handle.
+             */
+            if ((HWND)wParam == hWnd) break;
+
+            DPRINT1("WM_PALETTECHANGED ok\n");
+
+            // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
+            if (ActiveBuffer->PaletteHandle)
+            {
+                /* Get the Device Context of the console window */
+                HDC hDC = GetDC(GuiData->hWindow);
+
+                DPRINT1("WM_PALETTECHANGED changing palette\n");
+
+                /* Specify the use of the system palette */
+                SetSystemPaletteUse(hDC, ActiveBuffer->PaletteUsage);
+
+                /* Realize the (logical) palette */
+                RealizePalette(hDC);
+
+                /* Release the Device Context and return */
+                ReleaseDC(GuiData->hWindow, hDC);
+            }
+
+            DPRINT1("WM_PALETTECHANGED quit\n");
+
+            break;
+        }
+
         case WM_KEYDOWN:
         case WM_KEYUP:
         case WM_CHAR:
@@ -1772,14 +1975,16 @@ GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
              * call after that DefWindowProc, on ReactOS, right-clicks on the
              * (non-client) application title-bar does not display the system
              * menu and does not trigger a WM_NCRBUTTONUP message too.
-             * See: http://git.reactos.org/?p=reactos.git;a=blob;f=reactos/win32ss/user/user32/windows/defwnd.c;hb=HEAD#l1103
+             * See: http://git.reactos.org/?p=reactos.git;a=blob;f=reactos/win32ss/user/user32/windows/defwnd.c;hb=332bc8f482f40fd05ab510f78276576719fbfba8#l1103
              * and line 1135 too.
              */
+#if 0
             if (DefWindowProcW(hWnd, WM_NCHITTEST, 0, lParam) == HTCAPTION)
             {
                 /* Call DefWindowProcW with the WM_CONTEXTMENU message */
                 msg = WM_CONTEXTMENU;
             }
+#endif
             goto Default;
         }
         // case WM_NCRBUTTONUP:
@@ -1861,14 +2066,16 @@ GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
         {
             if (ConDrvValidateConsoleUnsafe(Console, CONSOLE_RUNNING, TRUE))
             {
+                BOOL SetFocus = (msg == WM_SETFOCUS);
                 INPUT_RECORD er;
+
                 er.EventType = FOCUS_EVENT;
-                er.Event.FocusEvent.bSetFocus = (msg == WM_SETFOCUS);
+                er.Event.FocusEvent.bSetFocus = SetFocus;
                 ConioProcessInputEvent(Console, &er);
 
-                if (msg == WM_SETFOCUS)
+                if (SetFocus)
                     DPRINT1("TODO: Create console caret\n");
-                else // if (msg == WM_KILLFOCUS)
+                else
                     DPRINT1("TODO: Destroy console caret\n");
 
                 LeaveCriticalSection(&Console->Lock);
@@ -1960,6 +2167,8 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
                                         (PVOID)GuiData);
             if (NULL != NewWindow)
             {
+                ASSERT(NewWindow == GuiData->hWindow);
+
                 WindowCount = GetWindowLongW(hWnd, GWL_USERDATA);
                 WindowCount++;
                 SetWindowLongW(hWnd, GWL_USERDATA, WindowCount);
@@ -1985,6 +2194,9 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
                 GuiConsoleResizeWindow(GuiData);
                 GuiData->WindowSizeLock = FALSE;
 
+                /* Switch to full-screen mode if necessary */
+                if (GuiData->GuiInfo.FullScreen) SwitchFullScreen(GuiData, TRUE);
+
                 // ShowWindow(NewWindow, (int)wParam);
                 ShowWindowAsync(NewWindow, (int)wParam);
                 DPRINT("Window showed\n");
@@ -1997,6 +2209,9 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
         {
             PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA)lParam;
 
+            /* Exit the full screen mode if it was already set */
+            // LeaveFullScreen(GuiData);
+
             /*
              * Window creation is done using a PostMessage(), so it's possible
              * that the window that we want to destroy doesn't exist yet.
@@ -2034,7 +2249,7 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
     }
 }
 
-static DWORD WINAPI
+static DWORD NTAPI
 GuiConsoleGuiThread(PVOID Data)
 {
     MSG msg;
@@ -2200,7 +2415,7 @@ GuiInit(VOID)
  *                             GUI Console Driver                             *
  ******************************************************************************/
 
-static VOID WINAPI
+static VOID NTAPI
 GuiDeinitFrontEnd(IN OUT PFRONTEND This);
 
 NTSTATUS NTAPI
@@ -2243,7 +2458,8 @@ GuiInitFrontEnd(IN OUT PFRONTEND This,
         return STATUS_UNSUCCESSFUL;
     }
     /* HACK */ Console->TermIFace.Data = (PVOID)GuiData; /* HACK */
-    GuiData->Console = Console;
+    GuiData->Console      = Console;
+    GuiData->ActiveBuffer = Console->ActiveBuffer;
     GuiData->hWindow = NULL;
 
     /* The console can be resized */
@@ -2275,12 +2491,13 @@ GuiInitFrontEnd(IN OUT PFRONTEND This,
          */
         if (ConsoleStartInfo->dwStartupFlags & STARTF_USESHOWWINDOW)
         {
-            TermInfo.ShowWindow = ConsoleStartInfo->ShowWindow;
+            TermInfo.ShowWindow = ConsoleStartInfo->wShowWindow;
         }
         if (ConsoleStartInfo->dwStartupFlags & STARTF_USEPOSITION)
         {
             TermInfo.AutoPosition = FALSE;
-            TermInfo.WindowOrigin = ConsoleStartInfo->ConsoleWindowOrigin;
+            TermInfo.WindowOrigin.x = ConsoleStartInfo->dwWindowOrigin.X;
+            TermInfo.WindowOrigin.y = ConsoleStartInfo->dwWindowOrigin.Y;
         }
         if (ConsoleStartInfo->dwStartupFlags & STARTF_RUNFULLSCREEN)
         {
@@ -2333,6 +2550,9 @@ GuiInitFrontEnd(IN OUT PFRONTEND This,
         }
     }
 
+    /* Original system palette */
+    GuiData->hSysPalette = NULL;
+
     /* Mouse is shown by default with its default cursor shape */
     GuiData->hCursor = ghDefaultCursor;
     GuiData->MouseCursorRefCount = 0;
@@ -2381,7 +2601,7 @@ GuiInitFrontEnd(IN OUT PFRONTEND This,
     return STATUS_SUCCESS;
 }
 
-static VOID WINAPI
+static VOID NTAPI
 GuiDeinitFrontEnd(IN OUT PFRONTEND This)
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
@@ -2408,7 +2628,7 @@ GuiDeinitFrontEnd(IN OUT PFRONTEND This)
     DPRINT("Quit GuiDeinitFrontEnd\n");
 }
 
-static VOID WINAPI
+static VOID NTAPI
 GuiDrawRegion(IN OUT PFRONTEND This,
               SMALL_RECT* Region)
 {
@@ -2420,7 +2640,7 @@ GuiDrawRegion(IN OUT PFRONTEND This,
     InvalidateRect(GuiData->hWindow, &RegionRect, FALSE);
 }
 
-static VOID WINAPI
+static VOID NTAPI
 GuiWriteStream(IN OUT PFRONTEND This,
                SMALL_RECT* Region,
                SHORT CursorStartX,
@@ -2436,7 +2656,7 @@ GuiWriteStream(IN OUT PFRONTEND This,
 
     if (NULL == GuiData || NULL == GuiData->hWindow) return;
 
-    Buff = ConDrvGetActiveScreenBuffer(GuiData->Console);
+    Buff = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console);
     if (GetType(Buff) != TEXTMODE_BUFFER) return;
 
     if (0 != ScrolledLines)
@@ -2479,13 +2699,13 @@ GuiWriteStream(IN OUT PFRONTEND This,
     SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
 }
 
-static BOOL WINAPI
+static BOOL NTAPI
 GuiSetCursorInfo(IN OUT PFRONTEND This,
                  PCONSOLE_SCREEN_BUFFER Buff)
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
 
-    if (ConDrvGetActiveScreenBuffer(GuiData->Console) == Buff)
+    if (/*ConDrvGetActiveScreenBuffer(GuiData->Console)*/GuiData->ActiveBuffer == Buff)
     {
         GuiInvalidateCell(This, Buff->CursorPosition.X, Buff->CursorPosition.Y);
     }
@@ -2493,7 +2713,7 @@ GuiSetCursorInfo(IN OUT PFRONTEND This,
     return TRUE;
 }
 
-static BOOL WINAPI
+static BOOL NTAPI
 GuiSetScreenInfo(IN OUT PFRONTEND This,
                  PCONSOLE_SCREEN_BUFFER Buff,
                  SHORT OldCursorX,
@@ -2501,7 +2721,7 @@ GuiSetScreenInfo(IN OUT PFRONTEND This,
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
 
-    if (ConDrvGetActiveScreenBuffer(GuiData->Console) == Buff)
+    if (/*ConDrvGetActiveScreenBuffer(GuiData->Console)*/GuiData->ActiveBuffer == Buff)
     {
         /* Redraw char at old position (remove cursor) */
         GuiInvalidateCell(This, OldCursorX, OldCursorY);
@@ -2512,7 +2732,7 @@ GuiSetScreenInfo(IN OUT PFRONTEND This,
     return TRUE;
 }
 
-static VOID WINAPI
+static VOID NTAPI
 GuiResizeTerminal(IN OUT PFRONTEND This)
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
@@ -2526,7 +2746,108 @@ GuiResizeTerminal(IN OUT PFRONTEND This)
     PostMessageW(GuiData->hWindow, PM_RESIZE_TERMINAL, 0, 0);
 }
 
-static BOOL WINAPI
+static VOID NTAPI
+GuiSetActiveScreenBuffer(IN OUT PFRONTEND This)
+{
+    PGUI_CONSOLE_DATA GuiData = This->Data;
+    PCONSOLE_SCREEN_BUFFER ActiveBuffer; // = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console);
+    HDC hDC;
+    HPALETTE hPalette;
+
+    EnterCriticalSection(&GuiData->Lock);
+    GuiData->WindowSizeLock = TRUE;
+
+    InterlockedExchangePointer(&GuiData->ActiveBuffer,
+                                GuiData->Console->ActiveBuffer);
+
+    GuiData->WindowSizeLock = FALSE;
+    LeaveCriticalSection(&GuiData->Lock);
+
+    ActiveBuffer = GuiData->ActiveBuffer;
+
+    /* Change the current palette */
+    if (ActiveBuffer->PaletteHandle == NULL)
+    {
+        hPalette = GuiData->hSysPalette;
+    }
+    else
+    {
+        hPalette = ActiveBuffer->PaletteHandle;
+    }
+
+    DPRINT1("GuiSetActiveScreenBuffer using palette 0x%p\n", hPalette);
+
+    /* Get the Device Context of the console window */
+    hDC = GetDC(GuiData->hWindow);
+
+    /* Set the new palette */
+    SelectPalette(hDC, hPalette, FALSE);
+
+    /* Specify the use of the system palette */
+    SetSystemPaletteUse(hDC, ActiveBuffer->PaletteUsage);
+
+    /* Realize the (logical) palette */
+    RealizePalette(hDC);
+
+    /* Release the Device Context */
+    ReleaseDC(GuiData->hWindow, hDC);
+
+    GuiResizeTerminal(This);
+    // ConioDrawConsole(Console);
+}
+
+static VOID NTAPI
+GuiReleaseScreenBuffer(IN OUT PFRONTEND This,
+                       IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
+{
+    PGUI_CONSOLE_DATA GuiData = This->Data;
+    HDC hDC;
+
+    /*
+     * If we were notified to release a screen buffer that is not actually
+     * ours, then just ignore the notification...
+     */
+    if (ScreenBuffer != GuiData->ActiveBuffer) return;
+
+    /*
+     * ... else, we must release our active buffer. Two cases are present:
+     * - If ScreenBuffer (== GuiData->ActiveBuffer) IS NOT the console
+     *   active screen buffer, then we can safely switch to it.
+     * - If ScreenBuffer IS the console active screen buffer, we must release
+     *   it ONLY.
+     */
+
+    /* Get the Device Context of the console window */
+    hDC = GetDC(GuiData->hWindow);
+
+    /* Release the old active palette and set the default one */
+    if (GetCurrentObject(hDC, OBJ_PAL) == ScreenBuffer->PaletteHandle)
+    {
+        /* Set the new palette */
+        SelectPalette(hDC, GuiData->hSysPalette, FALSE);
+    }
+
+    /* Release the Device Context */
+    ReleaseDC(GuiData->hWindow, hDC);
+
+    /* Set the adequate active screen buffer */
+    if (ScreenBuffer != GuiData->Console->ActiveBuffer)
+    {
+        GuiSetActiveScreenBuffer(This);
+    }
+    else
+    {
+        EnterCriticalSection(&GuiData->Lock);
+        GuiData->WindowSizeLock = TRUE;
+
+        InterlockedExchangePointer(&GuiData->ActiveBuffer, NULL);
+
+        GuiData->WindowSizeLock = FALSE;
+        LeaveCriticalSection(&GuiData->Lock);
+    }
+}
+
+static BOOL NTAPI
 GuiProcessKeyCallback(IN OUT PFRONTEND This,
                       MSG* msg,
                       BYTE KeyStateMenu,
@@ -2544,11 +2865,11 @@ GuiProcessKeyCallback(IN OUT PFRONTEND This,
     return FALSE;
 }
 
-static BOOL WINAPI
+static BOOL NTAPI
 GuiSetMouseCursor(IN OUT PFRONTEND This,
                   HCURSOR hCursor);
 
-static VOID WINAPI
+static VOID NTAPI
 GuiRefreshInternalInfo(IN OUT PFRONTEND This)
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
@@ -2570,7 +2891,7 @@ GuiRefreshInternalInfo(IN OUT PFRONTEND This)
     GuiSetMouseCursor(This, NULL);
 }
 
-static VOID WINAPI
+static VOID NTAPI
 GuiChangeTitle(IN OUT PFRONTEND This)
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
@@ -2578,7 +2899,7 @@ GuiChangeTitle(IN OUT PFRONTEND This)
     SetWindowText(GuiData->hWindow, GuiData->Console->Title.Buffer);
 }
 
-static BOOL WINAPI
+static BOOL NTAPI
 GuiChangeIcon(IN OUT PFRONTEND This,
               HICON hWindowIcon)
 {
@@ -2623,14 +2944,14 @@ GuiChangeIcon(IN OUT PFRONTEND This,
     return TRUE;
 }
 
-static HWND WINAPI
+static HWND NTAPI
 GuiGetConsoleWindowHandle(IN OUT PFRONTEND This)
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
     return GuiData->hWindow;
 }
 
-static VOID WINAPI
+static VOID NTAPI
 GuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
                                PCOORD pSize)
 {
@@ -2648,7 +2969,8 @@ GuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
         return;
     }
 
-    ActiveBuffer = ConDrvGetActiveScreenBuffer(GuiData->Console);
+    // ActiveBuffer = ConDrvGetActiveScreenBuffer(GuiData->Console);
+    ActiveBuffer = GuiData->ActiveBuffer;
     if (ActiveBuffer)
     {
         GetScreenBufferSizeUnits(ActiveBuffer, GuiData, &WidthUnit, &HeightUnit);
@@ -2673,7 +2995,62 @@ GuiGetLargestConsoleWindowSize(IN OUT PFRONTEND This,
     pSize->Y = (SHORT)(height / (int)HeightUnit) /* HACK */ + 1;
 }
 
-static ULONG WINAPI
+static BOOL NTAPI
+GuiSetPalette(IN OUT PFRONTEND This,
+              HPALETTE PaletteHandle,
+              UINT PaletteUsage)
+{
+    BOOL Success = TRUE;
+    PGUI_CONSOLE_DATA GuiData = This->Data;
+    // PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer; // ConDrvGetActiveScreenBuffer(GuiData->Console);
+    HDC hDC;
+    HPALETTE OldPalette;
+
+    DPRINT1("GuiSetPalette checkpt 0\n");
+
+    // if (GetType(ActiveBuffer) != GRAPHICS_BUFFER) return FALSE;
+    if (PaletteHandle == NULL) return FALSE;
+
+    DPRINT1("GuiSetPalette checkpt 1\n");
+
+    /* Get the Device Context of the console window */
+    hDC = GetDC(GuiData->hWindow);
+
+    DPRINT1("GuiSetPalette calling SelectPalette(0x%p, 0x%p, FALSE)\n", hDC, PaletteHandle);
+
+    /* Set the new palette */
+    OldPalette = SelectPalette(hDC, PaletteHandle, FALSE);
+    DPRINT1("OldPalette = 0x%p\n", OldPalette);
+    if (OldPalette == NULL)
+    {
+        DPRINT1("SelectPalette failed\n");
+        Success = FALSE;
+        goto Quit;
+    }
+
+    DPRINT1("GuiSetPalette checkpt 2\n");
+
+    /* Specify the use of the system palette */
+    SetSystemPaletteUse(hDC, PaletteUsage);
+
+    /* Realize the (logical) palette */
+    RealizePalette(hDC);
+
+    DPRINT1("GuiData->hSysPalette before == 0x%p\n", GuiData->hSysPalette);
+
+    /* Save the original system palette handle */
+    if (GuiData->hSysPalette == NULL) GuiData->hSysPalette = OldPalette;
+
+    DPRINT1("GuiData->hSysPalette after == 0x%p\n", GuiData->hSysPalette);
+
+Quit:
+    DPRINT1("GuiSetPalette Quit\n");
+    /* Release the Device Context and return */
+    ReleaseDC(GuiData->hWindow, hDC);
+    return Success;
+}
+
+static ULONG NTAPI
 GuiGetDisplayMode(IN OUT PFRONTEND This)
 {
     PGUI_CONSOLE_DATA GuiData = This->Data;
@@ -2687,7 +3064,7 @@ GuiGetDisplayMode(IN OUT PFRONTEND This)
     return DisplayMode;
 }
 
-static BOOL WINAPI
+static BOOL NTAPI
 GuiSetDisplayMode(IN OUT PFRONTEND This,
                   ULONG NewMode)
 {
@@ -2701,7 +3078,7 @@ GuiSetDisplayMode(IN OUT PFRONTEND This,
     return TRUE;
 }
 
-static INT WINAPI
+static INT NTAPI
 GuiShowMouseCursor(IN OUT PFRONTEND This,
                    BOOL Show)
 {
@@ -2717,7 +3094,7 @@ GuiShowMouseCursor(IN OUT PFRONTEND This,
     return GuiData->MouseCursorRefCount;
 }
 
-static BOOL WINAPI
+static BOOL NTAPI
 GuiSetMouseCursor(IN OUT PFRONTEND This,
                   HCURSOR hCursor)
 {
@@ -2735,7 +3112,7 @@ GuiSetMouseCursor(IN OUT PFRONTEND This,
     return TRUE;
 }
 
-static HMENU WINAPI
+static HMENU NTAPI
 GuiMenuControl(IN OUT PFRONTEND This,
                UINT cmdIdLow,
                UINT cmdIdHigh)
@@ -2748,7 +3125,7 @@ GuiMenuControl(IN OUT PFRONTEND This,
     return GetSystemMenu(GuiData->hWindow, FALSE);
 }
 
-static BOOL WINAPI
+static BOOL NTAPI
 GuiSetMenuClose(IN OUT PFRONTEND This,
                 BOOL Enable)
 {
@@ -2778,12 +3155,15 @@ static FRONTEND_VTBL GuiVtbl =
     GuiSetCursorInfo,
     GuiSetScreenInfo,
     GuiResizeTerminal,
+    GuiSetActiveScreenBuffer,
+    GuiReleaseScreenBuffer,
     GuiProcessKeyCallback,
     GuiRefreshInternalInfo,
     GuiChangeTitle,
     GuiChangeIcon,
     GuiGetConsoleWindowHandle,
     GuiGetLargestConsoleWindowSize,
+    GuiSetPalette,
     GuiGetDisplayMode,
     GuiSetDisplayMode,
     GuiShowMouseCursor,
@@ -2864,7 +3244,7 @@ LoadShellLinkConsoleInfo(IN OUT PCONSOLE_START_INFO ConsoleStartInfo,
 
                     /* Get the window showing command */
                     hRes = IShellLinkW_GetShowCmd(pshl, &ShowCmd);
-                    if (SUCCEEDED(hRes)) ConsoleStartInfo->ShowWindow = (WORD)ShowCmd;
+                    if (SUCCEEDED(hRes)) ConsoleStartInfo->wShowWindow = (WORD)ShowCmd;
 
                     /* Get the hotkey */
                     // hRes = pshl->GetHotkey(&ShowCmd);