[EXPLORER_NEW]
authorThomas Faber <thomas.faber@reactos.org>
Sun, 23 Dec 2012 14:31:18 +0000 (14:31 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Sun, 23 Dec 2012 14:31:18 +0000 (14:31 +0000)
- Run file dialog in its own thread
- Correctly check MapWindowPoints return value
- Fix a warning
- Based on Andrew Green's GSoC branch

svn path=/trunk/; revision=57977

reactos/base/shell/explorer-new/trayntfy.c
reactos/base/shell/explorer-new/traywnd.c

index 7aafa52..679fa6e 100644 (file)
@@ -401,7 +401,7 @@ TrayClockWnd_CalibrateTimer(IN OUT PTRAY_CLOCK_WND_DATA This)
 {
     UINT uiDueTime;
     BOOL Ret;
-    int intWait1, intWait2;
+    UINT uiWait1, uiWait2;
 
     /* Kill the initialization timer */
     KillTimer(This->hWnd,
@@ -412,23 +412,23 @@ TrayClockWnd_CalibrateTimer(IN OUT PTRAY_CLOCK_WND_DATA This)
 
     if (blShowSeconds == TRUE)
     {
-        intWait1 = 1000 - 200;
-        intWait2 = 1000;
+        uiWait1 = 1000 - 200;
+        uiWait2 = 1000;
     }
     else
     {
-        intWait1 = 60 * 1000 - 200;
-        intWait2 = 60 * 1000;
+        uiWait1 = 60 * 1000 - 200;
+        uiWait2 = 60 * 1000;
     }
 
-    if (uiDueTime > intWait1)
+    if (uiDueTime > uiWait1)
     {
         /* The update of the clock will be up to 200 ms late, but that's
            acceptable. We're going to setup a timer that fires depending
-           intWait2. */
+           uiWait2. */
         Ret = SetTimer(This->hWnd,
                        ID_TRAYCLOCK_TIMER,
-                       intWait2,
+                       uiWait2,
                        NULL) != 0;
         This->IsTimerEnabled = Ret;
 
index 21c3e27..0cdec7e 100644 (file)
@@ -1883,6 +1883,40 @@ static const ITrayWindowVtbl ITrayWindowImpl_Vtbl =
     ITrayWindowImpl_Lock
 };
 
+static DWORD WINAPI
+RunFileDlgThread(IN OUT PVOID pParam)
+{ 
+    ITrayWindowImpl *This = pParam;
+    HANDLE hShell32;
+    RUNFILEDLG RunFileDlg;
+    HWND hwnd;
+    RECT posRect;
+
+    GetWindowRect(This->hwndStart,&posRect);
+
+    hwnd = CreateWindowEx(0,
+                          WC_STATIC,
+                          NULL,
+                          WS_OVERLAPPED | WS_DISABLED | WS_CLIPSIBLINGS | WS_BORDER | SS_LEFT,
+                          posRect.left,
+                          posRect.top,
+                          posRect.right - posRect.left,
+                          posRect.bottom - posRect.top,
+                          NULL,
+                          NULL,
+                          NULL,
+                          NULL);
+
+    hShell32 = GetModuleHandle(TEXT("SHELL32.DLL"));
+    RunFileDlg = (RUNFILEDLG)GetProcAddress(hShell32, (LPCSTR)61);
+
+    RunFileDlg(hwnd, NULL, NULL, NULL, NULL, RFF_CALCDIRECTORY);
+
+    DestroyWindow(hwnd);
+
+    return 0; 
+}
+
 static LRESULT CALLBACK
 TrayWndProc(IN HWND hwnd,
             IN UINT uMsg,
@@ -1936,12 +1970,13 @@ TrayWndProc(IN HWND hwnd,
                     return HTBORDER;
                 }
 
+                SetLastError(ERROR_SUCCESS);
                 if (GetClientRect(hwnd,
                                   &rcClient) &&
-                    MapWindowPoints(hwnd,
-                                    NULL,
-                                    (LPPOINT)&rcClient,
-                                    2) != 0)
+                    (MapWindowPoints(hwnd,
+                                     NULL,
+                                     (LPPOINT)&rcClient,
+                                     2) != 0 || GetLastError() == ERROR_SUCCESS))
                 {
                     pt.x = (SHORT)LOWORD(lParam);
                     pt.y = (SHORT)HIWORD(lParam);
@@ -2382,13 +2417,13 @@ HandleTrayContextMenu:
 
                         case IDM_RUN:
                         {
-                            HANDLE hShell32;
-                            RUNFILEDLG RunFileDlg;
-
-                            hShell32 = GetModuleHandle(TEXT("SHELL32.DLL"));
-                            RunFileDlg = (RUNFILEDLG)GetProcAddress(hShell32, (LPCSTR)61);
+                            CloseHandle(CreateThread(NULL,
+                                                     0,
+                                                     RunFileDlgThread,
+                                                     This,
+                                                     0,
+                                                     NULL));
 
-                            RunFileDlg(hwnd, NULL, NULL, NULL, NULL, RFF_CALCDIRECTORY);
                             break;
                         }