[ros-diffs] [rharabien] 54957: [SHELL32] - Fix exception in shortcut properties dialog

rharabien at svn.reactos.org rharabien at svn.reactos.org
Sat Jan 14 13:46:34 UTC 2012


Author: rharabien
Date: Sat Jan 14 13:46:33 2012
New Revision: 54957

URL: http://svn.reactos.org/svn/reactos?rev=54957&view=rev
Log:
[SHELL32]
- Fix exception in shortcut properties dialog

Modified:
    trunk/reactos/dll/win32/shell32/shelllink.cpp

Modified: trunk/reactos/dll/win32/shell32/shelllink.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shelllink.cpp?rev=54957&r1=54956&r2=54957&view=diff
==============================================================================
--- trunk/reactos/dll/win32/shell32/shelllink.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shelllink.cpp [iso-8859-1] Sat Jan 14 13:46:33 2012
@@ -2000,22 +2000,13 @@
 
 INT_PTR CALLBACK CShellLink::SH_ShellLinkDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
-    LPPROPSHEETPAGEW ppsp;
-    LPPSHNOTIFY lppsn;
-    CShellLink *pThis;
-    HWND hDlgCtrl;
-    WCHAR szBuffer[MAX_PATH];
-    WCHAR * ptr;
-    int IconIndex;
-    INT_PTR result;
-
-    pThis = (CShellLink *)GetWindowLongPtr(hwndDlg, DWLP_USER);
+    CShellLink *pThis = (CShellLink *)GetWindowLongPtr(hwndDlg, DWLP_USER);
 
     switch(uMsg)
     {
         case WM_INITDIALOG:
         {
-            ppsp = (LPPROPSHEETPAGEW)lParam;
+            LPPROPSHEETPAGEW ppsp = (LPPROPSHEETPAGEW)lParam;
             if (ppsp == NULL)
                 break;
 
@@ -2028,61 +2019,61 @@
                 pThis->sIcoPath, pThis->sPath, pThis->sPathRel, pThis->sProduct, pThis->sWorkDir);
 
             /* target location */
-            wchar_t * wTrgtLocat;
-            const int ch = '\\';
-            wTrgtLocat = wcsrchr(pThis->sWorkDir, ch)+1;
-            SetDlgItemTextW(hwndDlg, 14007, wTrgtLocat);
+            if (pThis->sWorkDir)
+                SetDlgItemTextW(hwndDlg, 14007, PathFindFileName(pThis->sWorkDir));
 
             /* target path */
-            hDlgCtrl = GetDlgItem( hwndDlg, 14009 );
-            if ( hDlgCtrl != NULL )
-                SendMessageW( hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)pThis->sPath );
+            if (pThis->sPath)
+                SetDlgItemTextW(hwndDlg, 14009, pThis->sPath);
 
             /* working dir */
-            hDlgCtrl = GetDlgItem( hwndDlg, 14011 );
-            if ( hDlgCtrl != NULL )
-                SendMessageW( hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)pThis->sWorkDir );
+            if (pThis->sWorkDir)
+                SetDlgItemTextW(hwndDlg, 14011, pThis->sWorkDir);
 
             /* description */
-            hDlgCtrl = GetDlgItem( hwndDlg, 14019 );
-            if ( hDlgCtrl != NULL )
-                SendMessageW( hDlgCtrl, WM_SETTEXT, (WPARAM)NULL, (LPARAM)pThis->sDescription );
+            if (pThis->sDescription)
+                SetDlgItemTextW(hwndDlg, 14019, pThis->sDescription);
+
             return TRUE;
         }
-
         case WM_NOTIFY:
-            lppsn = (LPPSHNOTIFY) lParam;
-            if ( lppsn->hdr.code == PSN_APPLY )
+        {
+            LPPSHNOTIFY lppsn = (LPPSHNOTIFY)lParam;
+            if (lppsn->hdr.code == PSN_APPLY)
             {
+                WCHAR wszBuf[MAX_PATH];
+
                 /* set working directory */
-                GetDlgItemTextW(hwndDlg, 14011, szBuffer, MAX_PATH);
-                pThis->SetWorkingDirectory(szBuffer);
+                GetDlgItemTextW(hwndDlg, 14011, wszBuf, MAX_PATH);
+                pThis->SetWorkingDirectory(wszBuf);
                 /* set link destination */
-                GetDlgItemTextW(hwndDlg, 14009, szBuffer, MAX_PATH);
-                if ( !SHELL_ExistsFileW(szBuffer) )
+                GetDlgItemTextW(hwndDlg, 14009, wszBuf, MAX_PATH);
+                if (!PathFileExistsW(wszBuf))
                 {
                     //FIXME load localized error msg
-                    MessageBoxW( hwndDlg, L"file not existing", szBuffer, MB_OK );
-                    SetWindowLongPtr( hwndDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE );
+                    MessageBoxW(hwndDlg, L"file not existing", wszBuf, MB_OK);
+                    SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
                     return TRUE;
                 }
-                ptr = wcsrchr(szBuffer, L'.');
-                if (ptr && !_wcsnicmp(ptr, L".lnk", 4))
+
+                WCHAR *pwszExt = PathFindExtensionW(wszBuf);
+                if (!wcsicmp(pwszExt, L".lnk"))
                 {
                     // FIXME load localized error msg
-                    MessageBoxW( hwndDlg, L"You cannot create a link to a shortcut", L"Error", MB_ICONERROR );
-                    SetWindowLongPtr( hwndDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE );
+                    MessageBoxW(hwndDlg, L"You cannot create a link to a shortcut", L"Error", MB_ICONERROR);
+                    SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
                     return TRUE;
                 }
 
-                pThis->SetPath(szBuffer);
+                pThis->SetPath(wszBuf);
 
                 TRACE("This %p sLinkPath %S\n", pThis, pThis->sLinkPath);
-                pThis->Save(pThis->sLinkPath, TRUE );
-                SetWindowLongPtr( hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR );
+                pThis->Save(pThis->sLinkPath, TRUE);
+                SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR);
                 return TRUE;
             }
             break;
+        }
         case WM_COMMAND:
             switch(LOWORD(wParam))
             {
@@ -2093,21 +2084,27 @@
                     ///
                     return TRUE;
                 case 14021:
+                {
+                    WCHAR wszPath[MAX_PATH] = L"";
+
                     if (pThis->sIcoPath)
-                        wcscpy(szBuffer, pThis->sIcoPath);
-                    IconIndex = pThis->iIcoNdx;
-                    if (PickIconDlg(hwndDlg, szBuffer, MAX_PATH, &IconIndex))
+                        wcscpy(wszPath, pThis->sIcoPath);
+                    INT IconIndex = pThis->iIcoNdx;
+                    if (PickIconDlg(hwndDlg, wszPath, MAX_PATH, &IconIndex))
                     {
-                        pThis->SetIconLocation(szBuffer, IconIndex);
+                        pThis->SetIconLocation(wszPath, IconIndex);
                         ///
                         /// FIXME redraw icon
                     }
                     return TRUE;
+                }
+                    
                 case 14022:
-                    result = DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCEW(SHELL_EXTENDED_SHORTCUT_DLG), hwndDlg, ExtendedShortcutProc, (LPARAM)pThis->bRunAs);
+                {
+                    INT_PTR result = DialogBoxParamW(shell32_hInstance, MAKEINTRESOURCEW(SHELL_EXTENDED_SHORTCUT_DLG), hwndDlg, ExtendedShortcutProc, (LPARAM)pThis->bRunAs);
                     if (result == 1 || result == 0)
                     {
-                        if (pThis->bRunAs != result )
+                        if (pThis->bRunAs != result)
                         {
                             PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
                         }
@@ -2115,6 +2112,7 @@
                         pThis->bRunAs = result;
                     }
                     return TRUE;
+                }
             }
             switch(HIWORD(wParam))
             {




More information about the Ros-diffs mailing list