Author: akhaldi
Date: Tue Sep 13 13:13:35 2011
New Revision: 53702
URL:
http://svn.reactos.org/svn/reactos?rev=53702&view=rev
Log:
[SHELL32]
* Merge r53700. Point 3 in bug 6481 was fixed by fixing the parser (at line 414) to use
only ',' as the delimiter, to match Windows behavior.
Modified:
trunk/reactos/ (props changed)
trunk/reactos/dll/win32/shell32/control.cpp
Propchange: trunk/reactos/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 13 13:13:35 2011
@@ -8,5 +8,5 @@
/branches/reactx/reactos:49994-49995
/branches/ros-amd64-bringup:36852
/branches/ros-amd64-bringup/reactos:34711-34712,34741,34743,34770,34780-34782,34803,34812,34839,34842,34864,34870,34874,34877,34908-34909,34917,34965,35323-35324,35347-35348,35361,35436,35509,35515,35588,35655,35683,35739,35746,35762,35771,35777,35781,35789,35805,35823,35827,35902,35904-35906,35942,35947-35949,35952-35953,35966,36011-36013,36172,36360,36380,36388-36389,36393,36397,36443,36445,36475,36502-36503,36505,36570,36614,36852,36898-36899,36930,36936,36949,36951,36958,36961,36964,36969,36972,36987-36988,36990,36992,37019,37322-37323,37333-37334,37434,37472,37475,37536,37820-37821,37868-37869,37873,37990-37991,38013-38014,38092,38100,38148-38151,38264-38265,38268,38355,39151,39333,39335,39345,39639,40120,40122-40123,40125,40127-40128,40155,40247,40324,40608,40753,40926-40928,40986-40987,40989,40991,40993,40995-40996,41000-41001,41027-41030,41044-41045,41047-41050,41052,41070,41082-41086,41097-41098,41101,41449,41479-41480,41483-41485,41499-41500,41502,41531,41536,41540,41546-41547,41549,43080,43426,43451,43454,43506,43566,43574,43598,43600-43602,43604-43605,43677,43682,43757,43775,43836,43838-43840,43852,43857-43858,43860,43905-43907,43952,43954,43965,43969,43979,43981,43992,44002,44036-44037,44039-44040,44044-44045,44053,44065,44095,44123,44143-44144,44205,44238,44257,44259,44294,44338-44339,44385,44389,44391,44426,44460,44467-44468,44470-44471,44499,44501,44503-44504,44506,44510-44512,44521,44523-44526,44530,44540,44601,44634,44639,44772,44818,45124,45126-45127,45430,46394,46404,46478,46511,46523-46524,46526,46534-46535,46537-46539,46589,46805,46868,47472,47846-47847,47878,47882
-/branches/shell32_new-bringup:51893-53652,53661
+/branches/shell32_new-bringup:51893-53652,53661,53700
/branches/tcp-rewrite-branch:48720,48840-48841,49424-49426,49454
Modified: trunk/reactos/dll/win32/shell32/control.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/control.…
==============================================================================
--- trunk/reactos/dll/win32/shell32/control.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/control.cpp [iso-8859-1] Tue Sep 13 13:13:35 2011
@@ -27,11 +27,15 @@
unsigned i;
CPlApplet* next;
- for (i = 0; i < applet->count; i++) {
- if (!applet->info[i].dwSize) continue;
+ for (i = 0; i < applet->count; i++)
+ {
+ if (!applet->info[i].dwSize)
+ continue;
applet->proc(applet->hWnd, CPL_STOP, i, applet->info[i].lData);
}
- if (applet->proc) applet->proc(applet->hWnd, CPL_EXIT, 0L, 0L);
+ if (applet->proc)
+ applet->proc(applet->hWnd, CPL_EXIT, 0L, 0L);
+
FreeLibrary(applet->hModule);
next = applet->next;
HeapFree(GetProcessHeap(), 0, applet);
@@ -50,66 +54,75 @@
applet->hWnd = hWnd;
- if (!(applet->hModule = LoadLibraryW(cmd))) {
+ if (!(applet->hModule = LoadLibraryW(cmd)))
+ {
WARN("Cannot load control panel applet %s\n", debugstr_w(cmd));
- goto theError;
- }
- if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule,
"CPlApplet"))) {
+ goto theError;
+ }
+ if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule,
"CPlApplet")))
+ {
WARN("Not a valid control panel applet %s\n", debugstr_w(cmd));
- goto theError;
- }
- if (!applet->proc(hWnd, CPL_INIT, 0L, 0L)) {
+ goto theError;
+ }
+ if (!applet->proc(hWnd, CPL_INIT, 0L, 0L))
+ {
WARN("Init of applet has failed\n");
- goto theError;
- }
- if ((applet->count = applet->proc(hWnd, CPL_GETCOUNT, 0L, 0L)) == 0) {
+ goto theError;
+ }
+ if ((applet->count = applet->proc(hWnd, CPL_GETCOUNT, 0L, 0L)) == 0)
+ {
WARN("No subprogram in applet\n");
- goto theError;
+ goto theError;
}
applet = (CPlApplet *)HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet,
sizeof(*applet) + (applet->count - 1) * sizeof(NEWCPLINFOW));
- for (i = 0; i < applet->count; i++) {
- ZeroMemory(&newinfo, sizeof(newinfo));
- newinfo.dwSize = sizeof(NEWCPLINFOW);
- applet->info[i].dwSize = sizeof(NEWCPLINFOW);
+ for (i = 0; i < applet->count; i++)
+ {
+ ZeroMemory(&newinfo, sizeof(newinfo));
+ newinfo.dwSize = sizeof(NEWCPLINFOW);
+ applet->info[i].dwSize = sizeof(NEWCPLINFOW);
/* proc is supposed to return a null value upon success for
* CPL_INQUIRE and CPL_NEWINQUIRE
* However, real drivers don't seem to behave like this
* So, use introspection rather than return value
*/
- applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&newinfo);
- if (newinfo.hIcon == 0) {
- applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info);
- if (info.idIcon == 0 || info.idName == 0) {
- WARN("Couldn't get info from sp %u\n", i);
- applet->info[i].dwSize = 0;
- } else {
- /* convert the old data into the new structure */
- applet->info[i].dwFlags = 0;
- applet->info[i].dwHelpContext = 0;
- applet->info[i].lData = info.lData;
- applet->info[i].hIcon = LoadIconW(applet->hModule,
- MAKEINTRESOURCEW(info.idIcon));
- LoadStringW(applet->hModule, info.idName,
- applet->info[i].szName, sizeof(applet->info[i].szName) /
sizeof(WCHAR));
- LoadStringW(applet->hModule, info.idInfo,
- applet->info[i].szInfo, sizeof(applet->info[i].szInfo) /
sizeof(WCHAR));
- applet->info[i].szHelpFile[0] = '\0';
- }
- }
- else
- {
- CopyMemory(&applet->info[i], &newinfo, newinfo.dwSize);
- if (newinfo.dwSize != sizeof(NEWCPLINFOW))
- {
+ applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&newinfo);
+ if (newinfo.hIcon == 0)
+ {
+ applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info);
+ if (info.idIcon == 0 || info.idName == 0)
+ {
+ WARN("Couldn't get info from sp %u\n", i);
+ applet->info[i].dwSize = 0;
+ }
+ else
+ {
+ /* convert the old data into the new structure */
+ applet->info[i].dwFlags = 0;
+ applet->info[i].dwHelpContext = 0;
+ applet->info[i].lData = info.lData;
+ applet->info[i].hIcon = LoadIconW(applet->hModule,
+ MAKEINTRESOURCEW(info.idIcon));
+ LoadStringW(applet->hModule, info.idName,
+ applet->info[i].szName, sizeof(applet->info[i].szName) /
sizeof(WCHAR));
+ LoadStringW(applet->hModule, info.idInfo,
+ applet->info[i].szInfo, sizeof(applet->info[i].szInfo) /
sizeof(WCHAR));
+ applet->info[i].szHelpFile[0] = '\0';
+ }
+ }
+ else
+ {
+ CopyMemory(&applet->info[i], &newinfo, newinfo.dwSize);
+ if (newinfo.dwSize != sizeof(NEWCPLINFOW))
+ {
applet->info[i].dwSize = sizeof(NEWCPLINFOW);
lstrcpyW(applet->info[i].szName, newinfo.szName);
lstrcpyW(applet->info[i].szInfo, newinfo.szInfo);
lstrcpyW(applet->info[i].szHelpFile, newinfo.szHelpFile);
- }
- }
+ }
+ }
}
applet->next = panel->first;
@@ -145,20 +158,25 @@
RECT rc;
GetClientRect(panel->hWnd, &rc);
- for (applet = panel->first; applet; applet = applet->next) {
- for (i = 0; i < applet->count; i++) {
- if (!applet->info[i].dwSize) continue;
- if (x + XSTEP >= rc.right - rc.left) {
- x = (XSTEP-XICON)/2;
- y += YSTEP;
- }
- if (cx >= x && cx < x + XICON && cy >= y && cy
< y + YSTEP) {
- *papplet = applet;
- *psp = i;
- return TRUE;
- }
- x += XSTEP;
- }
+ for (applet = panel->first; applet; applet = applet->next)
+ {
+ for (i = 0; i < applet->count; i++)
+ {
+ if (!applet->info[i].dwSize)
+ continue;
+ if (x + XSTEP >= rc.right - rc.left)
+ {
+ x = (XSTEP-XICON)/2;
+ y += YSTEP;
+ }
+ if (cx >= x && cx < x + XICON && cy >= y &&
cy < y + YSTEP)
+ {
+ *papplet = applet;
+ *psp = i;
+ return TRUE;
+ }
+ x += XSTEP;
+ }
}
return FALSE;
}
@@ -176,25 +194,33 @@
hdc = (wParam) ? (HDC)wParam : BeginPaint(panel->hWnd, &ps);
hOldFont = SelectObject(hdc, GetStockObject(ANSI_VAR_FONT));
GetClientRect(panel->hWnd, &rc);
- for (applet = panel->first; applet; applet = applet->next) {
- for (i = 0; i < applet->count; i++) {
- if (x + XSTEP >= rc.right - rc.left) {
- x = 0;
- y += YSTEP;
- }
- if (!applet->info[i].dwSize) continue;
- DrawIcon(hdc, x + (XSTEP-XICON)/2, y, applet->info[i].hIcon);
- txtRect.left = x;
- txtRect.right = x + XSTEP;
- txtRect.top = y + YICON;
- txtRect.bottom = y + YSTEP;
- DrawTextW(hdc, applet->info[i].szName, -1, &txtRect,
- DT_CENTER | DT_VCENTER);
- x += XSTEP;
- }
- }
+
+ for (applet = panel->first; applet; applet = applet->next)
+ {
+ for (i = 0; i < applet->count; i++)
+ {
+ if (x + XSTEP >= rc.right - rc.left)
+ {
+ x = 0;
+ y += YSTEP;
+ }
+ if (!applet->info[i].dwSize)
+ continue;
+ DrawIcon(hdc, x + (XSTEP-XICON)/2, y, applet->info[i].hIcon);
+ txtRect.left = x;
+ txtRect.right = x + XSTEP;
+ txtRect.top = y + YICON;
+ txtRect.bottom = y + YSTEP;
+ DrawTextW(hdc, applet->info[i].szName, -1, &txtRect,
+ DT_CENTER | DT_VCENTER);
+ x += XSTEP;
+ }
+ }
+
SelectObject(hdc, hOldFont);
- if (!wParam) EndPaint(panel->hWnd, &ps);
+ if (!wParam)
+ EndPaint(panel->hWnd, &ps);
+
return 0;
}
@@ -203,15 +229,20 @@
unsigned i;
CPlApplet* applet;
- if (Control_Localize(panel, (short)LOWORD(lParam), (short)HIWORD(lParam),
&applet, &i)) {
- if (up) {
- if (panel->clkApplet == applet && panel->clkSP == i) {
- applet->proc(applet->hWnd, CPL_DBLCLK, i, applet->info[i].lData);
- }
- } else {
- panel->clkApplet = applet;
- panel->clkSP = i;
- }
+ if (Control_Localize(panel, (short)LOWORD(lParam), (short)HIWORD(lParam),
&applet, &i))
+ {
+ if (up)
+ {
+ if (panel->clkApplet == applet && panel->clkSP == i)
+ {
+ applet->proc(applet->hWnd, CPL_DBLCLK, i,
applet->info[i].lData);
+ }
+ }
+ else
+ {
+ panel->clkApplet = applet;
+ panel->clkSP = i;
+ }
}
return 0;
}
@@ -219,31 +250,35 @@
static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg,
WPARAM lParam1, LPARAM lParam2)
{
- CPanel* panel = (CPanel*)GetWindowLongPtrW(hWnd, 0);
-
- if (panel || wMsg == WM_CREATE) {
- switch (wMsg) {
- case WM_CREATE:
- Control_WndProc_Create(hWnd, (CREATESTRUCTW*)lParam2);
- return 0;
- case WM_DESTROY:
- {
- CPlApplet* applet = panel->first;
- while (applet)
- applet = Control_UnloadApplet(applet);
- }
- PostQuitMessage(0);
- break;
- case WM_PAINT:
- return Control_WndProc_Paint(panel, lParam1);
- case WM_LBUTTONUP:
- return Control_WndProc_LButton(panel, lParam2, TRUE);
- case WM_LBUTTONDOWN:
- return Control_WndProc_LButton(panel, lParam2, FALSE);
-/* EPP case WM_COMMAND: */
-/* EPP return Control_WndProc_Command(mwi, lParam1, lParam2); */
- }
- }
+ CPanel* panel = (CPanel*)GetWindowLongPtrW(hWnd, 0);
+
+ if (panel || wMsg == WM_CREATE)
+ {
+ switch (wMsg)
+ {
+ case WM_CREATE:
+ Control_WndProc_Create(hWnd, (CREATESTRUCTW*)lParam2);
+ return 0;
+
+ case WM_DESTROY:
+ {
+ CPlApplet* applet = panel->first;
+ while (applet)
+ applet = Control_UnloadApplet(applet);
+
+ PostQuitMessage(0);
+ }; break;
+
+ case WM_PAINT:
+ return Control_WndProc_Paint(panel, lParam1);
+ case WM_LBUTTONUP:
+ return Control_WndProc_LButton(panel, lParam2, TRUE);
+ case WM_LBUTTONDOWN:
+ return Control_WndProc_LButton(panel, lParam2, FALSE);
+ /* EPP case WM_COMMAND: */
+ /* EPP return Control_WndProc_Command(mwi, lParam1, lParam2); */
+ }
+ }
return DefWindowProcW(hWnd, wMsg, lParam1, lParam2);
}
@@ -271,15 +306,19 @@
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, NULL, hInst, panel);
- if (!panel->hWnd) return;
-
- if (!panel->first) {
- /* FIXME appName & message should be localized */
- MessageBoxW(panel->hWnd, L"Cannot load any applets", appName, MB_OK);
- return;
- }
-
- while (GetMessageW(&msg, panel->hWnd, 0, 0)) {
+
+ if (!panel->hWnd)
+ return;
+
+ if (!panel->first)
+ {
+ /* FIXME appName & message should be localized */
+ MessageBoxW(panel->hWnd, L"Cannot load any applets", appName,
MB_OK);
+ return;
+ }
+
+ while (GetMessageW(&msg, panel->hWnd, 0, 0))
+ {
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
@@ -298,12 +337,14 @@
*p++ = '\\';
wcscpy(p, wszAllCpl);
- if ((h = FindFirstFileW(buffer, &fd)) != INVALID_HANDLE_VALUE) {
- do {
- wcscpy(p, fd.cFileName);
- Control_LoadApplet(hWnd, buffer, panel);
- } while (FindNextFileW(h, &fd));
- FindClose(h);
+ if ((h = FindFirstFileW(buffer, &fd)) != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ wcscpy(p, fd.cFileName);
+ Control_LoadApplet(hWnd, buffer, panel);
+ } while (FindNextFileW(h, &fd));
+ FindClose(h);
}
Control_DoInterface(panel, hWnd, hInst);
@@ -360,68 +401,92 @@
CloseHandle(hMutex);
return;
}
+
+ TRACE("[shell32, Control_DoLaunch] wszCmd = %ws\n", wszCmd);
+
end = wcscpy(buffer, wszCmd);
- for (;;) {
- ch = *end;
- if (ch == '"') quoted = !quoted;
- if (!quoted && (ch == ' ' || ch == ',' || ch ==
'\0')) {
- *end = '\0';
- if (beg) {
- if (*beg == '@') {
- sp = atoiW(beg + 1);
- spSet = TRUE;
- } else if (*beg == '\0') {
+ for (;;)
+ {
+ ch = *end;
+ if (ch == '"')
+ quoted = !quoted;
+
+ if (!quoted && (ch == ',' || ch == '\0'))
+ {
+ *end = '\0';
+ if (beg)
+ {
+ if (*beg == '@')
+ {
+ sp = atoiW(beg + 1);
+ spSet = TRUE;
+ }
+ else if (*beg == '\0')
+ {
+ sp = 0;
+ spSet = TRUE;
+ }
+ else
+ {
+ extraPmts = beg;
+ }
+ }
+
+ if (ch == '\0') break;
+ beg = end + 1;
+ if (ch == ' ')
+ while (end[1] == ' ')
+ end++;
+ }
+ end++;
+ }
+ while ((ptr = StrChrW(buffer, '"')))
+ memmove((LPVOID)ptr, ptr+1, wcslen(ptr)*sizeof(WCHAR));
+
+ while ((ptr = StrChrW(extraPmts, '"')))
+ memmove((LPVOID)ptr, ptr+1, wcslen(ptr)*sizeof(WCHAR));
+
+ TRACE("[shell32, Control_DoLaunch] cmd %s, extra %s, sp %d\n",
debugstr_w(buffer), debugstr_w(extraPmts), sp);
+
+ Control_LoadApplet(hWnd, buffer, panel);
+
+ if (panel->first)
+ {
+ CPlApplet* applet = panel->first;
+
+ TRACE("[shell32, Control_DoLaunch] applet->count %d,
applet->info[sp].szName %ws\n", applet->count, applet->info[sp].szName);
+
+ assert(applet && applet->next == NULL);
+ if (sp >= applet->count)
+ {
+ WARN("Out of bounds (%u >= %u), setting to 0\n", sp,
applet->count);
sp = 0;
- spSet = TRUE;
- } else {
- extraPmts = beg;
- }
- }
- if (ch == '\0') break;
- beg = end + 1;
- if (ch == ' ') while (end[1] == ' ') end++;
- }
- end++;
- }
- while ((ptr = StrChrW(buffer, '"')))
- memmove((LPVOID)ptr, ptr+1, wcslen(ptr)*sizeof(WCHAR));
-
- while ((ptr = StrChrW(extraPmts, '"')))
- memmove((LPVOID)ptr, ptr+1, wcslen(ptr)*sizeof(WCHAR));
-
- TRACE("cmd %s, extra %s, sp %d\n", debugstr_w(buffer),
debugstr_w(extraPmts), sp);
-
- Control_LoadApplet(hWnd, buffer, panel);
-
- if (panel->first) {
- CPlApplet* applet = panel->first;
-
- assert(applet && applet->next == NULL);
- if (sp >= applet->count) {
- WARN("Out of bounds (%u >= %u), setting to 0\n", sp,
applet->count);
- sp = 0;
- }
-
- if ((extraPmts) && extraPmts[0] &&(!spSet))
- {
- while ((lstrcmpiW(extraPmts, applet->info[sp].szName)) && (sp <
applet->count))
- sp++;
-
- if (sp >= applet->count)
- {
- ReleaseMutex(hMutex);
- CloseHandle(hMutex);
- Control_UnloadApplet(applet);
- HeapFree(GetProcessHeap(), 0, buffer);
- return;
- }
- }
- if (applet->info[sp].dwSize) {
- if (!applet->proc(applet->hWnd, CPL_DBLCLK, sp,
applet->info[sp].lData))
- applet->proc(applet->hWnd, CPL_STARTWPARMSA, sp, (LPARAM)extraPmts);
- }
- Control_UnloadApplet(applet);
- }
+ }
+
+ if ((extraPmts) && extraPmts[0] && (!spSet))
+ {
+ while ((lstrcmpiW(extraPmts, applet->info[sp].szName)) && (sp <
applet->count))
+ sp++;
+
+ if (sp >= applet->count)
+ {
+ ReleaseMutex(hMutex);
+ CloseHandle(hMutex);
+ Control_UnloadApplet(applet);
+ HeapFree(GetProcessHeap(), 0, buffer);
+ return;
+ }
+ }
+
+ if (applet->info[sp].dwSize)
+ {
+ if (!applet->proc(applet->hWnd, CPL_DBLCLK, sp,
applet->info[sp].lData))
+ applet->proc(applet->hWnd, CPL_STARTWPARMSA, sp,
(LPARAM)extraPmts);
+ }
+
+ Control_UnloadApplet(applet);
+ }
+
ReleaseMutex(hMutex);
CloseHandle(hMutex);
HeapFree(GetProcessHeap(), 0, buffer);
@@ -440,9 +505,14 @@
memset(&panel, 0, sizeof(panel));
- if (!cmd || !*cmd) {
+ if (!cmd || !*cmd)
+ {
+ TRACE("[shell32, Control_RunDLLW] Calling Control_DoWindow\n");
Control_DoWindow(&panel, hWnd, hInst);
- } else {
+ }
+ else
+ {
+ TRACE("[shell32, Control_RunDLLW] Calling Control_DoLaunch\n");
Control_DoLaunch(&panel, hWnd, cmd);
}
}
@@ -455,10 +525,12 @@
{
DWORD len = MultiByteToWideChar(CP_ACP, 0, cmd, -1, NULL, 0 );
LPWSTR wszCmd = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+
if (wszCmd && MultiByteToWideChar(CP_ACP, 0, cmd, -1, wszCmd, len ))
{
Control_RunDLLW(hWnd, hInst, wszCmd, nCmdShow);
}
+
HeapFree(GetProcessHeap(), 0, wszCmd);
}