Author: janderwald
Date: Thu Mar  3 21:22:47 2011
New Revision: 50964
URL: 
http://svn.reactos.org/svn/reactos?rev=50964&view=rev
Log:
[SHELL32]
- Return the icon index, not the icon id
- Fixes bug 5742
Modified:
    trunk/reactos/dll/win32/shell32/dialogs.c
Modified: trunk/reactos/dll/win32/shell32/dialogs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/dialogs.…
==============================================================================
--- trunk/reactos/dll/win32/shell32/dialogs.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/dialogs.c [iso-8859-1] Thu Mar  3 21:22:47 2011
@@ -63,7 +63,7 @@
     PPICK_ICON_CONTEXT pIconContext = (PPICK_ICON_CONTEXT)lParam;
     if (IS_INTRESOURCE(lpszName))
-        swprintf(szName, L"%u\n", lpszName);
+        swprintf(szName, L"%u", lpszName);
     else
         wcscpy(szName, (WCHAR*)lpszName);
@@ -105,7 +105,7 @@
     LPMEASUREITEMSTRUCT lpmis;
     LPDRAWITEMSTRUCT lpdis;
     HICON hIcon;
-    INT index;
+    INT index, count;
     WCHAR szText[MAX_PATH], szTitle[100], szFilter[100];
     OPENFILENAMEW ofn = {0};
@@ -123,18 +123,21 @@
         else
             SendDlgItemMessageW(hwndDlg, IDC_EDIT_PATH, WM_SETTEXT, 0,
(LPARAM)pIconContext->szName);
-        swprintf(szText, L"%u", pIconContext->Index);
-        index = SendMessageW(pIconContext->hDlgCtrl, LB_FINDSTRING, -1,
(LPARAM)szText);
-        if (index != LB_ERR)
-            SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, index, 0);
+        count = SendMessage(pIconContext->hDlgCtrl, LB_GETCOUNT, 0, 0);
+        if (count != LB_ERR)
+        {
+            if (count > pIconContext->Index)
+                SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL,
pIconContext->Index, 0);
+            else
+                SendMessageW(pIconContext->hDlgCtrl, LB_SETCURSEL, 0, 0);
+        }
         return TRUE;
     case WM_COMMAND:
         switch(LOWORD(wParam))
         {
         case IDOK:
             index = SendMessageW(pIconContext->hDlgCtrl, LB_GETCURSEL, 0, 0);
-            SendMessageW(pIconContext->hDlgCtrl, LB_GETTEXT, index, (LPARAM)szText);
-            pIconContext->Index = _wtoi(szText);
+            pIconContext->Index = index;
             SendDlgItemMessageW(hwndDlg, IDC_EDIT_PATH, WM_GETTEXT, MAX_PATH,
(LPARAM)pIconContext->szName);
             DestroyIconList(pIconContext->hDlgCtrl);
             EndDialog(hwndDlg, 1);