2002-03-10 00:29:33 +01:00
|
|
|
/* Control Panel management
|
|
|
|
*
|
|
|
|
* Copyright 2001 Eric Pouech
|
2008-07-22 18:31:03 +02:00
|
|
|
* Copyright 2008 Owen Rudge
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
*/
|
2001-02-23 02:12:26 +01:00
|
|
|
|
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-02-23 02:12:26 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2001-02-23 02:12:26 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2008-07-02 19:08:42 +02:00
|
|
|
#include "winreg.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-02-23 02:12:26 +01:00
|
|
|
#include "cpl.h"
|
2008-07-24 23:10:33 +02:00
|
|
|
#include "commctrl.h"
|
2002-12-13 03:17:54 +01:00
|
|
|
|
|
|
|
#define NO_SHLWAPI_REG
|
|
|
|
#include "shlwapi.h"
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2004-03-27 02:42:22 +01:00
|
|
|
#include "cpanel.h"
|
2008-07-22 18:30:51 +02:00
|
|
|
#include "shresdef.h"
|
|
|
|
#include "shell32_main.h"
|
|
|
|
|
|
|
|
#define MAX_STRING_LEN 1024
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2004-03-27 02:42:22 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shlctrl);
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2012-06-05 19:55:27 +02:00
|
|
|
void Control_UnloadApplet(CPlApplet* applet)
|
2001-02-23 02:12:26 +01:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
2012-06-06 11:46:20 +02:00
|
|
|
for (i = 0; i < applet->count; i++)
|
2012-02-16 12:37:27 +01:00
|
|
|
applet->proc(applet->hWnd, CPL_STOP, i, applet->info[i].data);
|
2012-06-06 11:46:20 +02:00
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
if (applet->proc) applet->proc(applet->hWnd, CPL_EXIT, 0L, 0L);
|
|
|
|
FreeLibrary(applet->hModule);
|
2012-06-05 19:55:27 +02:00
|
|
|
list_remove( &applet->entry );
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(applet->cmd);
|
|
|
|
heap_free(applet);
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
|
|
|
|
2004-03-27 02:42:22 +01:00
|
|
|
CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
|
2001-02-23 02:12:26 +01:00
|
|
|
{
|
|
|
|
CPlApplet* applet;
|
2014-04-09 15:27:31 +02:00
|
|
|
DWORD len;
|
2001-02-23 02:12:26 +01:00
|
|
|
unsigned i;
|
|
|
|
CPLINFO info;
|
2002-12-13 03:17:54 +01:00
|
|
|
NEWCPLINFOW newinfo;
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
if (!(applet = heap_alloc_zero(sizeof(*applet))))
|
2001-02-23 02:12:26 +01:00
|
|
|
return applet;
|
|
|
|
|
2014-04-09 15:27:31 +02:00
|
|
|
len = ExpandEnvironmentStringsW(cmd, NULL, 0);
|
|
|
|
if (len > 0)
|
|
|
|
{
|
2018-02-22 08:43:28 +01:00
|
|
|
if (!(applet->cmd = heap_alloc((len+1) * sizeof(WCHAR))))
|
2014-04-09 15:27:31 +02:00
|
|
|
{
|
|
|
|
WARN("Cannot allocate memory for applet path\n");
|
|
|
|
goto theError;
|
|
|
|
}
|
|
|
|
ExpandEnvironmentStringsW(cmd, applet->cmd, len+1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("Cannot expand applet path\n");
|
2012-06-06 11:46:20 +02:00
|
|
|
goto theError;
|
|
|
|
}
|
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
applet->hWnd = hWnd;
|
|
|
|
|
2014-04-09 15:27:31 +02:00
|
|
|
if (!(applet->hModule = LoadLibraryW(applet->cmd))) {
|
|
|
|
WARN("Cannot load control panel applet %s\n", debugstr_w(applet->cmd));
|
2001-02-23 02:12:26 +01:00
|
|
|
goto theError;
|
|
|
|
}
|
|
|
|
if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule, "CPlApplet"))) {
|
2014-04-09 15:27:31 +02:00
|
|
|
WARN("Not a valid control panel applet %s\n", debugstr_w(applet->cmd));
|
2001-02-23 02:12:26 +01:00
|
|
|
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) {
|
|
|
|
WARN("No subprogram in applet\n");
|
2012-06-06 11:46:20 +02:00
|
|
|
applet->proc(applet->hWnd, CPL_EXIT, 0, 0);
|
2001-02-23 02:12:26 +01:00
|
|
|
goto theError;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
applet = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet,
|
2012-06-06 11:46:20 +02:00
|
|
|
FIELD_OFFSET( CPlApplet, info[applet->count] ));
|
2009-07-20 22:03:58 +02:00
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
for (i = 0; i < applet->count; i++) {
|
2002-12-13 03:17:54 +01:00
|
|
|
ZeroMemory(&newinfo, sizeof(newinfo));
|
|
|
|
newinfo.dwSize = sizeof(NEWCPLINFOA);
|
2012-02-16 12:37:27 +01:00
|
|
|
applet->info[i].helpfile[0] = 0;
|
2001-02-23 02:12:26 +01:00
|
|
|
/* 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
|
|
|
|
*/
|
2008-02-13 22:30:53 +01:00
|
|
|
applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info);
|
2012-02-16 12:37:27 +01:00
|
|
|
applet->info[i].data = info.lData;
|
2008-02-13 22:30:53 +01:00
|
|
|
if (info.idIcon != CPL_DYNAMIC_RES)
|
2012-02-16 12:37:27 +01:00
|
|
|
applet->info[i].icon = LoadIconW(applet->hModule, MAKEINTRESOURCEW(info.idIcon));
|
2008-02-13 22:30:53 +01:00
|
|
|
if (info.idName != CPL_DYNAMIC_RES)
|
|
|
|
LoadStringW(applet->hModule, info.idName,
|
2018-03-19 08:11:27 +01:00
|
|
|
applet->info[i].name, ARRAY_SIZE(applet->info[i].name));
|
2008-02-13 22:30:53 +01:00
|
|
|
if (info.idInfo != CPL_DYNAMIC_RES)
|
|
|
|
LoadStringW(applet->hModule, info.idInfo,
|
2018-03-19 08:11:27 +01:00
|
|
|
applet->info[i].info, ARRAY_SIZE(applet->info[i].info));
|
2008-02-13 22:30:53 +01:00
|
|
|
|
2008-09-19 01:13:58 +02:00
|
|
|
/* some broken control panels seem to return incorrect values in CPL_INQUIRE,
|
|
|
|
but proper data in CPL_NEWINQUIRE. if we get an empty string or a null
|
|
|
|
icon, see what we can get from CPL_NEWINQUIRE */
|
|
|
|
|
2012-02-16 12:37:27 +01:00
|
|
|
if (!applet->info[i].name[0]) info.idName = CPL_DYNAMIC_RES;
|
2008-09-19 01:13:58 +02:00
|
|
|
|
|
|
|
/* zero-length szInfo may not be a buggy applet, but it doesn't hurt for us
|
|
|
|
to check anyway */
|
|
|
|
|
2012-02-16 12:37:27 +01:00
|
|
|
if (!applet->info[i].info[0]) info.idInfo = CPL_DYNAMIC_RES;
|
2008-09-19 01:13:58 +02:00
|
|
|
|
2012-02-16 12:37:27 +01:00
|
|
|
if (applet->info[i].icon == NULL)
|
2008-09-19 01:13:58 +02:00
|
|
|
info.idIcon = CPL_DYNAMIC_RES;
|
|
|
|
|
2008-02-13 22:30:53 +01:00
|
|
|
if ((info.idIcon == CPL_DYNAMIC_RES) || (info.idName == CPL_DYNAMIC_RES) ||
|
|
|
|
(info.idInfo == CPL_DYNAMIC_RES)) {
|
|
|
|
applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&newinfo);
|
|
|
|
|
2012-02-16 12:37:27 +01:00
|
|
|
applet->info[i].data = newinfo.lData;
|
2008-02-13 22:30:53 +01:00
|
|
|
if (info.idIcon == CPL_DYNAMIC_RES) {
|
|
|
|
if (!newinfo.hIcon) WARN("couldn't get icon for applet %u\n", i);
|
2012-02-16 12:37:27 +01:00
|
|
|
applet->info[i].icon = newinfo.hIcon;
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
2008-02-13 22:30:53 +01:00
|
|
|
if (newinfo.dwSize == sizeof(NEWCPLINFOW)) {
|
|
|
|
if (info.idName == CPL_DYNAMIC_RES)
|
2012-02-16 12:37:27 +01:00
|
|
|
memcpy(applet->info[i].name, newinfo.szName, sizeof(newinfo.szName));
|
2008-02-13 22:30:53 +01:00
|
|
|
if (info.idInfo == CPL_DYNAMIC_RES)
|
2012-02-16 12:37:27 +01:00
|
|
|
memcpy(applet->info[i].info, newinfo.szInfo, sizeof(newinfo.szInfo));
|
|
|
|
memcpy(applet->info[i].helpfile, newinfo.szHelpFile, sizeof(newinfo.szHelpFile));
|
2008-02-13 22:30:53 +01:00
|
|
|
} else {
|
2018-03-19 08:11:27 +01:00
|
|
|
NEWCPLINFOA *infoA = (NEWCPLINFOA *)&newinfo;
|
|
|
|
|
2008-02-13 22:30:53 +01:00
|
|
|
if (info.idName == CPL_DYNAMIC_RES)
|
2018-03-19 08:11:27 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, infoA->szName, ARRAY_SIZE(infoA->szName),
|
|
|
|
applet->info[i].name, ARRAY_SIZE(applet->info[i].name));
|
2008-02-13 22:30:53 +01:00
|
|
|
if (info.idInfo == CPL_DYNAMIC_RES)
|
2018-03-19 08:11:27 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, infoA->szInfo, ARRAY_SIZE(infoA->szInfo),
|
|
|
|
applet->info[i].info, ARRAY_SIZE(applet->info[i].info));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, infoA->szHelpFile, ARRAY_SIZE(infoA->szHelpFile),
|
|
|
|
applet->info[i].helpfile, ARRAY_SIZE(applet->info[i].helpfile));
|
2002-12-13 03:17:54 +01:00
|
|
|
}
|
|
|
|
}
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
|
|
|
|
2012-06-05 19:55:27 +02:00
|
|
|
list_add_head( &panel->applets, &applet->entry );
|
2001-02-23 02:12:26 +01:00
|
|
|
return applet;
|
|
|
|
|
|
|
|
theError:
|
2012-06-06 11:46:20 +02:00
|
|
|
FreeLibrary(applet->hModule);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(applet->cmd);
|
|
|
|
heap_free(applet);
|
2001-02-23 02:12:26 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-07-24 23:10:33 +02:00
|
|
|
#define IDC_LISTVIEW 1000
|
2008-07-24 23:10:41 +02:00
|
|
|
#define IDC_STATUSBAR 1001
|
2008-07-24 23:10:33 +02:00
|
|
|
|
|
|
|
#define NUM_COLUMNS 2
|
|
|
|
#define LISTVIEW_DEFSTYLE (WS_CHILD | WS_VISIBLE | WS_TABSTOP |\
|
|
|
|
LVS_SORTASCENDING | LVS_AUTOARRANGE | LVS_SINGLESEL)
|
|
|
|
|
|
|
|
static BOOL Control_CreateListView (CPanel *panel)
|
|
|
|
{
|
2018-01-04 13:02:48 +01:00
|
|
|
static const WCHAR empty_string[] = {0};
|
2008-07-24 23:10:41 +02:00
|
|
|
RECT ws, sb;
|
2008-07-24 23:10:33 +02:00
|
|
|
WCHAR buf[MAX_STRING_LEN];
|
|
|
|
LVCOLUMNW lvc;
|
|
|
|
|
|
|
|
/* Create list view */
|
2008-07-24 23:10:41 +02:00
|
|
|
GetClientRect(panel->hWndStatusBar, &sb);
|
2008-07-24 23:10:33 +02:00
|
|
|
GetClientRect(panel->hWnd, &ws);
|
|
|
|
|
|
|
|
panel->hWndListView = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW,
|
|
|
|
empty_string, LISTVIEW_DEFSTYLE | LVS_ICON,
|
2008-07-24 23:10:41 +02:00
|
|
|
0, 0, ws.right - ws.left, ws.bottom - ws.top -
|
|
|
|
(sb.bottom - sb.top), panel->hWnd,
|
|
|
|
(HMENU) IDC_LISTVIEW, panel->hInst, NULL);
|
2008-07-24 23:10:33 +02:00
|
|
|
|
|
|
|
if (!panel->hWndListView)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Create image lists for list view */
|
|
|
|
panel->hImageListSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
|
2010-06-13 16:50:43 +02:00
|
|
|
GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 1, 1);
|
2008-07-24 23:10:33 +02:00
|
|
|
panel->hImageListLarge = ImageList_Create(GetSystemMetrics(SM_CXICON),
|
2010-06-13 16:50:43 +02:00
|
|
|
GetSystemMetrics(SM_CYICON), ILC_COLOR32 | ILC_MASK, 1, 1);
|
2008-07-24 23:10:33 +02:00
|
|
|
|
2009-05-10 10:11:53 +02:00
|
|
|
SendMessageW(panel->hWndListView, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)panel->hImageListSmall);
|
|
|
|
SendMessageW(panel->hWndListView, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)panel->hImageListLarge);
|
2008-07-24 23:10:33 +02:00
|
|
|
|
|
|
|
/* Create columns for list view */
|
|
|
|
lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;
|
|
|
|
lvc.pszText = buf;
|
|
|
|
lvc.fmt = LVCFMT_LEFT;
|
|
|
|
|
|
|
|
/* Name column */
|
|
|
|
lvc.iSubItem = 0;
|
|
|
|
lvc.cx = (ws.right - ws.left) / 3;
|
2018-03-19 08:11:27 +01:00
|
|
|
LoadStringW(shell32_hInstance, IDS_CPANEL_NAME, buf, ARRAY_SIZE(buf));
|
2008-07-24 23:10:33 +02:00
|
|
|
|
|
|
|
if (ListView_InsertColumnW(panel->hWndListView, 0, &lvc) == -1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Description column */
|
|
|
|
lvc.iSubItem = 1;
|
|
|
|
lvc.cx = ((ws.right - ws.left) / 3) * 2;
|
2018-03-19 08:11:27 +01:00
|
|
|
LoadStringW(shell32_hInstance, IDS_CPANEL_DESCRIPTION, buf, ARRAY_SIZE(buf));
|
2008-07-24 23:10:33 +02:00
|
|
|
|
|
|
|
if (ListView_InsertColumnW(panel->hWndListView, 1, &lvc) == -1)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return(TRUE);
|
|
|
|
}
|
|
|
|
|
2008-07-21 20:22:54 +02:00
|
|
|
static void Control_WndProc_Create(HWND hWnd, const CREATESTRUCTW* cs)
|
2001-02-23 02:12:26 +01:00
|
|
|
{
|
2009-02-18 22:46:39 +01:00
|
|
|
CPanel* panel = cs->lpCreateParams;
|
2008-07-22 18:31:03 +02:00
|
|
|
HMENU hMenu, hSubMenu;
|
2009-02-18 22:46:39 +01:00
|
|
|
CPlApplet* applet;
|
2008-07-22 18:31:03 +02:00
|
|
|
MENUITEMINFOW mii;
|
2008-11-11 23:27:29 +01:00
|
|
|
unsigned int i;
|
|
|
|
int menucount, index;
|
2008-07-22 18:31:03 +02:00
|
|
|
CPlItem *item;
|
2008-07-24 23:10:33 +02:00
|
|
|
LVITEMW lvItem;
|
|
|
|
INITCOMMONCONTROLSEX icex;
|
2008-07-24 23:10:41 +02:00
|
|
|
INT sb_parts;
|
2008-07-28 17:14:49 +02:00
|
|
|
int itemidx;
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2008-07-21 20:22:54 +02:00
|
|
|
SetWindowLongPtrW(hWnd, 0, (LONG_PTR)panel);
|
2001-02-23 02:12:26 +01:00
|
|
|
panel->hWnd = hWnd;
|
2008-07-22 18:31:03 +02:00
|
|
|
|
2008-07-24 23:10:33 +02:00
|
|
|
/* Initialise common control DLL */
|
|
|
|
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
2008-07-24 23:10:41 +02:00
|
|
|
icex.dwICC = ICC_LISTVIEW_CLASSES | ICC_BAR_CLASSES;
|
2008-07-24 23:10:33 +02:00
|
|
|
InitCommonControlsEx(&icex);
|
|
|
|
|
2008-07-24 23:10:41 +02:00
|
|
|
/* create the status bar */
|
|
|
|
if (!(panel->hWndStatusBar = CreateStatusWindowW(WS_CHILD | WS_VISIBLE | CCS_BOTTOM | SBARS_SIZEGRIP, NULL, hWnd, IDC_STATUSBAR)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
sb_parts = -1;
|
|
|
|
SendMessageW(panel->hWndStatusBar, SB_SETPARTS, 1, (LPARAM) &sb_parts);
|
|
|
|
|
2008-07-24 23:10:33 +02:00
|
|
|
/* create the list view */
|
|
|
|
if (!Control_CreateListView(panel))
|
|
|
|
return;
|
|
|
|
|
2008-07-22 18:31:03 +02:00
|
|
|
hMenu = LoadMenuW(shell32_hInstance, MAKEINTRESOURCEW(MENU_CPANEL));
|
|
|
|
|
|
|
|
/* insert menu items for applets */
|
|
|
|
hSubMenu = GetSubMenu(hMenu, 0);
|
|
|
|
menucount = 0;
|
|
|
|
|
2012-06-05 19:55:27 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( applet, &panel->applets, CPlApplet, entry )
|
|
|
|
{
|
2008-07-22 18:31:03 +02:00
|
|
|
for (i = 0; i < applet->count; i++) {
|
|
|
|
/* set up a CPlItem for this particular subprogram */
|
2018-02-22 08:43:28 +01:00
|
|
|
item = heap_alloc(sizeof(CPlItem));
|
2008-07-22 18:31:03 +02:00
|
|
|
|
|
|
|
if (!item)
|
|
|
|
continue;
|
|
|
|
|
2009-02-18 22:46:39 +01:00
|
|
|
item->applet = applet;
|
2008-07-22 18:31:03 +02:00
|
|
|
item->id = i;
|
|
|
|
|
|
|
|
mii.cbSize = sizeof(MENUITEMINFOW);
|
|
|
|
mii.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA;
|
2012-02-16 12:37:27 +01:00
|
|
|
mii.dwTypeData = applet->info[i].name;
|
2018-03-19 08:11:27 +01:00
|
|
|
mii.cch = ARRAY_SIZE(applet->info[i].name);
|
2008-07-22 18:31:03 +02:00
|
|
|
mii.wID = IDM_CPANEL_APPLET_BASE + menucount;
|
2009-01-08 17:27:41 +01:00
|
|
|
mii.dwItemData = (ULONG_PTR)item;
|
2008-07-22 18:31:03 +02:00
|
|
|
|
|
|
|
if (InsertMenuItemW(hSubMenu, menucount, TRUE, &mii)) {
|
2008-07-24 23:10:33 +02:00
|
|
|
/* add the list view item */
|
2012-06-05 19:54:23 +02:00
|
|
|
HICON icon = applet->info[i].icon;
|
|
|
|
if (!icon) icon = LoadImageW( 0, (LPCWSTR)IDI_WINLOGO, IMAGE_ICON, 0, 0, LR_SHARED );
|
|
|
|
index = ImageList_AddIcon(panel->hImageListLarge, icon);
|
|
|
|
ImageList_AddIcon(panel->hImageListSmall, icon);
|
2008-07-24 23:10:33 +02:00
|
|
|
|
|
|
|
lvItem.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
|
|
|
|
lvItem.iItem = menucount;
|
|
|
|
lvItem.iSubItem = 0;
|
2012-02-16 12:37:27 +01:00
|
|
|
lvItem.pszText = applet->info[i].name;
|
2008-07-24 23:10:33 +02:00
|
|
|
lvItem.iImage = index;
|
|
|
|
lvItem.lParam = (LPARAM) item;
|
|
|
|
|
2008-07-28 17:14:49 +02:00
|
|
|
itemidx = ListView_InsertItemW(panel->hWndListView, &lvItem);
|
2008-07-24 23:10:33 +02:00
|
|
|
|
|
|
|
/* add the description */
|
2012-02-16 12:37:27 +01:00
|
|
|
ListView_SetItemTextW(panel->hWndListView, itemidx, 1, applet->info[i].info);
|
2008-07-24 23:10:33 +02:00
|
|
|
|
|
|
|
/* update menu bar, increment count */
|
|
|
|
DrawMenuBar(hWnd);
|
|
|
|
menucount++;
|
2008-07-22 18:31:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
panel->total_subprogs = menucount;
|
|
|
|
|
|
|
|
/* check the "large items" icon in the View menu */
|
|
|
|
hSubMenu = GetSubMenu(hMenu, 1);
|
|
|
|
CheckMenuRadioItem(hSubMenu, FCIDM_SHVIEW_BIGICON, FCIDM_SHVIEW_REPORTVIEW,
|
|
|
|
FCIDM_SHVIEW_BIGICON, MF_BYCOMMAND);
|
|
|
|
|
|
|
|
SetMenu(hWnd, hMenu);
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
|
|
|
|
2008-07-22 18:31:03 +02:00
|
|
|
static void Control_FreeCPlItems(HWND hWnd, CPanel *panel)
|
|
|
|
{
|
|
|
|
HMENU hMenu, hSubMenu;
|
|
|
|
MENUITEMINFOW mii;
|
2008-11-11 23:27:29 +01:00
|
|
|
unsigned int i;
|
2008-07-22 18:31:03 +02:00
|
|
|
|
|
|
|
/* get the File menu */
|
|
|
|
hMenu = GetMenu(hWnd);
|
|
|
|
|
|
|
|
if (!hMenu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hSubMenu = GetSubMenu(hMenu, 0);
|
|
|
|
|
|
|
|
if (!hSubMenu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* loop and free the item data */
|
|
|
|
for (i = IDM_CPANEL_APPLET_BASE; i <= IDM_CPANEL_APPLET_BASE + panel->total_subprogs; i++)
|
|
|
|
{
|
|
|
|
mii.cbSize = sizeof(MENUITEMINFOW);
|
|
|
|
mii.fMask = MIIM_DATA;
|
|
|
|
|
|
|
|
if (!GetMenuItemInfoW(hSubMenu, i, FALSE, &mii))
|
|
|
|
continue;
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free((void *)mii.dwItemData);
|
2008-07-22 18:31:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-24 23:10:33 +02:00
|
|
|
static void Control_UpdateListViewStyle(CPanel *panel, UINT style, UINT id)
|
|
|
|
{
|
|
|
|
HMENU hMenu, hSubMenu;
|
|
|
|
|
|
|
|
SetWindowLongW(panel->hWndListView, GWL_STYLE, LISTVIEW_DEFSTYLE | style);
|
|
|
|
|
|
|
|
/* update the menu */
|
|
|
|
hMenu = GetMenu(panel->hWnd);
|
|
|
|
hSubMenu = GetSubMenu(hMenu, 1);
|
|
|
|
|
|
|
|
CheckMenuRadioItem(hSubMenu, FCIDM_SHVIEW_BIGICON, FCIDM_SHVIEW_REPORTVIEW,
|
|
|
|
id, MF_BYCOMMAND);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CPlItem* Control_GetCPlItem_From_MenuID(HWND hWnd, UINT id)
|
|
|
|
{
|
|
|
|
HMENU hMenu, hSubMenu;
|
|
|
|
MENUITEMINFOW mii;
|
|
|
|
|
|
|
|
/* retrieve the CPlItem structure from the menu item data */
|
|
|
|
hMenu = GetMenu(hWnd);
|
|
|
|
|
|
|
|
if (!hMenu)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hSubMenu = GetSubMenu(hMenu, 0);
|
|
|
|
|
|
|
|
if (!hSubMenu)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
mii.cbSize = sizeof(MENUITEMINFOW);
|
|
|
|
mii.fMask = MIIM_DATA;
|
|
|
|
|
|
|
|
if (!GetMenuItemInfoW(hSubMenu, id, FALSE, &mii))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return (CPlItem *) mii.dwItemData;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CPlItem* Control_GetCPlItem_From_ListView(CPanel *panel)
|
|
|
|
{
|
|
|
|
LVITEMW lvItem;
|
|
|
|
int selitem;
|
|
|
|
|
|
|
|
selitem = SendMessageW(panel->hWndListView, LVM_GETNEXTITEM, -1, LVNI_FOCUSED
|
|
|
|
| LVNI_SELECTED);
|
|
|
|
|
|
|
|
if (selitem != -1)
|
|
|
|
{
|
|
|
|
lvItem.iItem = selitem;
|
|
|
|
lvItem.mask = LVIF_PARAM;
|
|
|
|
|
|
|
|
if (SendMessageW(panel->hWndListView, LVM_GETITEMW, 0, (LPARAM) &lvItem))
|
|
|
|
return (CPlItem *) lvItem.lParam;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-07-20 22:03:58 +02:00
|
|
|
static void Control_StartApplet(HWND hWnd, CPlItem *item)
|
|
|
|
{
|
2021-09-20 12:58:52 +02:00
|
|
|
WCHAR param[12];
|
2009-07-20 22:03:58 +02:00
|
|
|
|
|
|
|
/* execute the applet if item is valid */
|
|
|
|
if (item)
|
|
|
|
{
|
2021-09-20 12:58:52 +02:00
|
|
|
swprintf(param, ARRAY_SIZE(param), L"@%d", item->id);
|
|
|
|
ShellExecuteW(hWnd, L"cplopen", item->applet->cmd, param, NULL, SW_SHOW);
|
2009-07-20 22:03:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg,
|
2001-02-23 02:12:26 +01:00
|
|
|
WPARAM lParam1, LPARAM lParam2)
|
|
|
|
{
|
2008-07-21 20:22:54 +02:00
|
|
|
CPanel* panel = (CPanel*)GetWindowLongPtrW(hWnd, 0);
|
2001-02-23 02:12:26 +01:00
|
|
|
|
|
|
|
if (panel || wMsg == WM_CREATE) {
|
|
|
|
switch (wMsg) {
|
|
|
|
case WM_CREATE:
|
2008-07-21 20:22:54 +02:00
|
|
|
Control_WndProc_Create(hWnd, (CREATESTRUCTW*)lParam2);
|
2001-02-23 02:12:26 +01:00
|
|
|
return 0;
|
|
|
|
case WM_DESTROY:
|
2003-12-11 05:24:16 +01:00
|
|
|
{
|
2012-06-05 19:55:27 +02:00
|
|
|
CPlApplet *applet, *next;
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE( applet, next, &panel->applets, CPlApplet, entry )
|
|
|
|
Control_UnloadApplet(applet);
|
2003-12-11 05:24:16 +01:00
|
|
|
}
|
2008-07-22 18:31:03 +02:00
|
|
|
Control_FreeCPlItems(hWnd, panel);
|
2003-12-11 05:24:16 +01:00
|
|
|
PostQuitMessage(0);
|
2001-02-23 02:12:26 +01:00
|
|
|
break;
|
2008-07-22 18:31:08 +02:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(lParam1))
|
|
|
|
{
|
|
|
|
case IDM_CPANEL_EXIT:
|
|
|
|
SendMessageW(hWnd, WM_CLOSE, 0, 0);
|
|
|
|
return 0;
|
|
|
|
|
2008-07-22 18:31:14 +02:00
|
|
|
case IDM_CPANEL_ABOUT:
|
|
|
|
{
|
|
|
|
WCHAR appName[MAX_STRING_LEN];
|
2010-05-06 14:44:09 +02:00
|
|
|
HICON icon = LoadImageW(shell32_hInstance, MAKEINTRESOURCEW(IDI_SHELL_CONTROL_PANEL),
|
|
|
|
IMAGE_ICON, 48, 48, LR_SHARED);
|
2008-07-22 18:31:14 +02:00
|
|
|
|
2018-03-19 08:11:27 +01:00
|
|
|
LoadStringW(shell32_hInstance, IDS_CPANEL_TITLE, appName, ARRAY_SIZE(appName));
|
2010-05-05 11:00:38 +02:00
|
|
|
ShellAboutW(hWnd, appName, NULL, icon);
|
2008-07-22 18:31:14 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-22 18:31:08 +02:00
|
|
|
case FCIDM_SHVIEW_BIGICON:
|
2008-07-24 23:10:33 +02:00
|
|
|
Control_UpdateListViewStyle(panel, LVS_ICON, FCIDM_SHVIEW_BIGICON);
|
|
|
|
return 0;
|
|
|
|
|
2008-07-22 18:31:08 +02:00
|
|
|
case FCIDM_SHVIEW_SMALLICON:
|
2008-07-24 23:10:33 +02:00
|
|
|
Control_UpdateListViewStyle(panel, LVS_SMALLICON, FCIDM_SHVIEW_SMALLICON);
|
|
|
|
return 0;
|
|
|
|
|
2008-07-22 18:31:08 +02:00
|
|
|
case FCIDM_SHVIEW_LISTVIEW:
|
2008-07-24 23:10:33 +02:00
|
|
|
Control_UpdateListViewStyle(panel, LVS_LIST, FCIDM_SHVIEW_LISTVIEW);
|
|
|
|
return 0;
|
|
|
|
|
2008-07-22 18:31:08 +02:00
|
|
|
case FCIDM_SHVIEW_REPORTVIEW:
|
2008-07-24 23:10:33 +02:00
|
|
|
Control_UpdateListViewStyle(panel, LVS_REPORT, FCIDM_SHVIEW_REPORTVIEW);
|
2008-07-22 18:31:08 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* check if this is an applet */
|
|
|
|
if ((LOWORD(lParam1) >= IDM_CPANEL_APPLET_BASE) &&
|
|
|
|
(LOWORD(lParam1) <= IDM_CPANEL_APPLET_BASE + panel->total_subprogs))
|
|
|
|
{
|
2009-07-20 22:03:58 +02:00
|
|
|
Control_StartApplet(hWnd, Control_GetCPlItem_From_MenuID(hWnd, LOWORD(lParam1)));
|
2008-07-22 18:31:08 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2008-07-24 23:10:33 +02:00
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
LPNMHDR nmh = (LPNMHDR) lParam2;
|
|
|
|
|
|
|
|
switch (nmh->idFrom)
|
|
|
|
{
|
|
|
|
case IDC_LISTVIEW:
|
|
|
|
switch (nmh->code)
|
|
|
|
{
|
|
|
|
case NM_RETURN:
|
|
|
|
case NM_DBLCLK:
|
|
|
|
{
|
2009-07-20 22:03:58 +02:00
|
|
|
Control_StartApplet(hWnd, Control_GetCPlItem_From_ListView(panel));
|
2008-07-24 23:10:33 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-07-24 23:10:41 +02:00
|
|
|
case LVN_ITEMCHANGED:
|
|
|
|
{
|
|
|
|
CPlItem *item = Control_GetCPlItem_From_ListView(panel);
|
|
|
|
|
|
|
|
/* update the status bar if item is valid */
|
|
|
|
if (item)
|
2012-02-16 12:37:27 +01:00
|
|
|
SetWindowTextW(panel->hWndStatusBar, item->applet->info[item->id].info);
|
2008-07-28 17:15:46 +02:00
|
|
|
else
|
|
|
|
SetWindowTextW(panel->hWndStatusBar, NULL);
|
2008-07-24 23:10:41 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-24 23:10:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-07-24 23:10:41 +02:00
|
|
|
case WM_MENUSELECT:
|
|
|
|
/* check if this is an applet */
|
|
|
|
if ((LOWORD(lParam1) >= IDM_CPANEL_APPLET_BASE) &&
|
|
|
|
(LOWORD(lParam1) <= IDM_CPANEL_APPLET_BASE + panel->total_subprogs))
|
|
|
|
{
|
|
|
|
CPlItem *item = Control_GetCPlItem_From_MenuID(hWnd, LOWORD(lParam1));
|
|
|
|
|
|
|
|
/* update the status bar if item is valid */
|
|
|
|
if (item)
|
2012-02-16 12:37:27 +01:00
|
|
|
SetWindowTextW(panel->hWndStatusBar, item->applet->info[item->id].info);
|
2008-07-24 23:10:41 +02:00
|
|
|
}
|
2008-07-28 17:15:46 +02:00
|
|
|
else if ((HIWORD(lParam1) == 0xFFFF) && (lParam2 == 0))
|
|
|
|
{
|
|
|
|
/* reset status bar description to that of the selected icon */
|
|
|
|
CPlItem *item = Control_GetCPlItem_From_ListView(panel);
|
|
|
|
|
|
|
|
if (item)
|
2012-02-16 12:37:27 +01:00
|
|
|
SetWindowTextW(panel->hWndStatusBar, item->applet->info[item->id].info);
|
2008-07-28 17:15:46 +02:00
|
|
|
else
|
|
|
|
SetWindowTextW(panel->hWndStatusBar, NULL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-24 23:10:41 +02:00
|
|
|
else
|
|
|
|
SetWindowTextW(panel->hWndStatusBar, NULL);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2008-07-24 23:10:33 +02:00
|
|
|
case WM_SIZE:
|
|
|
|
{
|
2008-07-24 23:10:41 +02:00
|
|
|
HDWP hdwp;
|
|
|
|
RECT sb;
|
|
|
|
|
|
|
|
hdwp = BeginDeferWindowPos(2);
|
|
|
|
|
|
|
|
if (hdwp == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
GetClientRect(panel->hWndStatusBar, &sb);
|
|
|
|
|
|
|
|
hdwp = DeferWindowPos(hdwp, panel->hWndListView, NULL, 0, 0,
|
|
|
|
LOWORD(lParam2), HIWORD(lParam2) - (sb.bottom - sb.top),
|
|
|
|
SWP_NOZORDER | SWP_NOMOVE);
|
|
|
|
|
|
|
|
if (hdwp == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
hdwp = DeferWindowPos(hdwp, panel->hWndStatusBar, NULL, 0, 0,
|
|
|
|
LOWORD(lParam2), LOWORD(lParam1), SWP_NOZORDER | SWP_NOMOVE);
|
2008-07-24 23:10:33 +02:00
|
|
|
|
2008-07-24 23:10:41 +02:00
|
|
|
if (hdwp != NULL)
|
|
|
|
EndDeferWindowPos(hdwp);
|
2008-07-24 23:10:33 +02:00
|
|
|
|
|
|
|
return 0;
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
2008-07-24 23:10:33 +02:00
|
|
|
}
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
|
|
|
|
2008-07-21 20:22:54 +02:00
|
|
|
return DefWindowProcW(hWnd, wMsg, lParam1, lParam2);
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Control_DoInterface(CPanel* panel, HWND hWnd, HINSTANCE hInst)
|
|
|
|
{
|
2010-05-05 11:00:38 +02:00
|
|
|
WNDCLASSEXW wc;
|
2001-02-23 02:12:26 +01:00
|
|
|
MSG msg;
|
2008-07-22 18:30:51 +02:00
|
|
|
WCHAR appName[MAX_STRING_LEN];
|
2008-07-21 20:22:54 +02:00
|
|
|
|
2018-03-19 08:11:27 +01:00
|
|
|
LoadStringW(shell32_hInstance, IDS_CPANEL_TITLE, appName, ARRAY_SIZE(appName));
|
2008-07-22 18:30:51 +02:00
|
|
|
|
2010-06-18 23:42:44 +02:00
|
|
|
wc.cbSize = sizeof(wc);
|
2001-02-23 02:12:26 +01:00
|
|
|
wc.style = CS_HREDRAW|CS_VREDRAW;
|
|
|
|
wc.lpfnWndProc = Control_WndProc;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = sizeof(CPlApplet*);
|
2008-07-24 23:10:33 +02:00
|
|
|
wc.hInstance = panel->hInst = hInst;
|
2010-05-06 14:44:09 +02:00
|
|
|
wc.hIcon = LoadIconW( shell32_hInstance, MAKEINTRESOURCEW(IDI_SHELL_CONTROL_PANEL) );
|
2008-07-23 11:52:12 +02:00
|
|
|
wc.hCursor = LoadCursorW( 0, (LPWSTR)IDC_ARROW );
|
2001-02-23 02:12:26 +01:00
|
|
|
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
wc.lpszMenuName = NULL;
|
2021-09-20 12:58:52 +02:00
|
|
|
wc.lpszClassName = L"Shell_Control_WndClass";
|
2010-05-06 14:44:09 +02:00
|
|
|
wc.hIconSm = LoadImageW( shell32_hInstance, MAKEINTRESOURCEW(IDI_SHELL_CONTROL_PANEL), IMAGE_ICON,
|
2010-05-05 11:00:38 +02:00
|
|
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2010-05-05 11:00:38 +02:00
|
|
|
if (!RegisterClassExW(&wc)) return;
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2008-07-21 20:22:54 +02:00
|
|
|
CreateWindowExW(0, wc.lpszClassName, appName,
|
2002-06-01 01:06:46 +02:00
|
|
|
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
2002-12-02 19:10:57 +01:00
|
|
|
hWnd, NULL, hInst, panel);
|
2001-02-23 02:12:26 +01:00
|
|
|
if (!panel->hWnd) return;
|
2003-12-11 05:24:16 +01:00
|
|
|
|
2019-11-12 23:01:59 +01:00
|
|
|
while (GetMessageW(&msg, 0, 0, 0)) {
|
2001-02-23 02:12:26 +01:00
|
|
|
TranslateMessage(&msg);
|
2008-07-21 20:22:54 +02:00
|
|
|
DispatchMessageW(&msg);
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-02 19:08:42 +02:00
|
|
|
static void Control_RegisterRegistryApplets(HWND hWnd, CPanel *panel, HKEY hkey_root, LPCWSTR szRepPath)
|
|
|
|
{
|
|
|
|
WCHAR name[MAX_PATH];
|
|
|
|
WCHAR value[MAX_PATH];
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
if (RegOpenKeyW(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
int idx = 0;
|
|
|
|
|
|
|
|
for(;; ++idx)
|
|
|
|
{
|
|
|
|
DWORD nameLen = MAX_PATH;
|
|
|
|
DWORD valueLen = MAX_PATH;
|
|
|
|
|
2008-07-14 19:44:17 +02:00
|
|
|
if (RegEnumValueW(hkey, idx, name, &nameLen, NULL, NULL, (LPBYTE)value, &valueLen) != ERROR_SUCCESS)
|
2008-07-02 19:08:42 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
Control_LoadApplet(hWnd, value, panel);
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
static void Control_DoWindow(CPanel* panel, HWND hWnd, HINSTANCE hInst)
|
|
|
|
{
|
|
|
|
HANDLE h;
|
2002-12-13 03:17:54 +01:00
|
|
|
WIN32_FIND_DATAW fd;
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
WCHAR *p;
|
|
|
|
|
2008-07-02 19:08:42 +02:00
|
|
|
/* first add .cpl files in the system directory */
|
2002-12-13 03:17:54 +01:00
|
|
|
GetSystemDirectoryW( buffer, MAX_PATH );
|
2021-09-17 17:16:11 +02:00
|
|
|
p = buffer + lstrlenW(buffer);
|
2002-12-13 03:17:54 +01:00
|
|
|
*p++ = '\\';
|
2021-09-20 12:58:52 +02:00
|
|
|
lstrcpyW(p, L"*.cpl");
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2003-12-11 05:24:16 +01:00
|
|
|
if ((h = FindFirstFileW(buffer, &fd)) != INVALID_HANDLE_VALUE) {
|
2001-02-23 02:12:26 +01:00
|
|
|
do {
|
2002-12-13 03:17:54 +01:00
|
|
|
lstrcpyW(p, fd.cFileName);
|
2001-02-23 02:12:26 +01:00
|
|
|
Control_LoadApplet(hWnd, buffer, panel);
|
2002-12-13 03:17:54 +01:00
|
|
|
} while (FindNextFileW(h, &fd));
|
2001-02-23 02:12:26 +01:00
|
|
|
FindClose(h);
|
|
|
|
}
|
|
|
|
|
2008-07-02 19:08:42 +02:00
|
|
|
/* now check for cpls in the registry */
|
2021-09-20 12:58:52 +02:00
|
|
|
Control_RegisterRegistryApplets(hWnd, panel, HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
|
|
|
|
Control_RegisterRegistryApplets(hWnd, panel, HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cpls");
|
2008-07-02 19:08:42 +02:00
|
|
|
|
2003-12-11 05:24:16 +01:00
|
|
|
Control_DoInterface(panel, hWnd, hInst);
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
|
|
|
|
2002-12-13 03:17:54 +01:00
|
|
|
static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
|
2001-02-23 02:12:26 +01:00
|
|
|
/* forms to parse:
|
|
|
|
* foo.cpl,@sp,str
|
|
|
|
* foo.cpl,@sp
|
|
|
|
* foo.cpl,,str
|
|
|
|
* foo.cpl @sp
|
|
|
|
* foo.cpl str
|
2002-11-01 02:46:02 +01:00
|
|
|
* "a path\foo.cpl"
|
2001-02-23 02:12:26 +01:00
|
|
|
*/
|
|
|
|
{
|
2002-12-13 03:17:54 +01:00
|
|
|
LPWSTR buffer;
|
|
|
|
LPWSTR beg = NULL;
|
|
|
|
LPWSTR end;
|
|
|
|
WCHAR ch;
|
|
|
|
LPWSTR ptr;
|
2008-06-23 19:54:11 +02:00
|
|
|
signed sp = -1;
|
|
|
|
LPWSTR extraPmtsBuf = NULL;
|
2002-12-13 03:17:54 +01:00
|
|
|
LPWSTR extraPmts = NULL;
|
2013-10-22 00:16:09 +02:00
|
|
|
BOOL quoted = FALSE;
|
2012-06-05 19:55:27 +02:00
|
|
|
CPlApplet *applet;
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
buffer = heap_alloc((lstrlenW(wszCmd) + 1) * sizeof(*wszCmd));
|
2001-02-23 02:12:26 +01:00
|
|
|
if (!buffer) return;
|
|
|
|
|
2002-12-13 03:17:54 +01:00
|
|
|
end = lstrcpyW(buffer, wszCmd);
|
2001-02-23 02:12:26 +01:00
|
|
|
|
|
|
|
for (;;) {
|
2008-06-23 19:54:11 +02:00
|
|
|
ch = *end;
|
2002-10-23 20:44:13 +02:00
|
|
|
if (ch == '"') quoted = !quoted;
|
2008-06-23 19:54:11 +02:00
|
|
|
if (!quoted && (ch == ' ' || ch == ',' || ch == '\0')) {
|
|
|
|
*end = '\0';
|
|
|
|
if (beg) {
|
|
|
|
if (*beg == '@') {
|
2021-09-17 17:16:11 +02:00
|
|
|
sp = wcstol(beg + 1, NULL, 10);
|
2008-06-23 19:54:11 +02:00
|
|
|
} else if (*beg == '\0') {
|
|
|
|
sp = -1;
|
|
|
|
} else {
|
|
|
|
extraPmtsBuf = beg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ch == '\0') break;
|
|
|
|
beg = end + 1;
|
|
|
|
if (ch == ' ') while (end[1] == ' ') end++;
|
|
|
|
}
|
|
|
|
end++;
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
2002-12-13 03:17:54 +01:00
|
|
|
while ((ptr = StrChrW(buffer, '"')))
|
2003-10-27 23:06:56 +01:00
|
|
|
memmove(ptr, ptr+1, lstrlenW(ptr)*sizeof(WCHAR));
|
2002-10-23 20:44:13 +02:00
|
|
|
|
2008-06-23 19:54:11 +02:00
|
|
|
/* now check for any quotes in extraPmtsBuf and remove */
|
|
|
|
if (extraPmtsBuf != NULL)
|
|
|
|
{
|
|
|
|
beg = end = extraPmtsBuf;
|
2013-10-22 00:16:09 +02:00
|
|
|
quoted = FALSE;
|
2008-06-23 19:54:11 +02:00
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
ch = *end;
|
|
|
|
if (ch == '"') quoted = !quoted;
|
|
|
|
if (!quoted && (ch == ' ' || ch == ',' || ch == '\0')) {
|
|
|
|
*end = '\0';
|
|
|
|
if (beg) {
|
|
|
|
if (*beg != '\0') {
|
|
|
|
extraPmts = beg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ch == '\0') break;
|
2012-12-20 22:55:34 +01:00
|
|
|
beg = end + 1;
|
2008-06-23 19:54:11 +02:00
|
|
|
if (ch == ' ') while (end[1] == ' ') end++;
|
|
|
|
}
|
|
|
|
end++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((ptr = StrChrW(extraPmts, '"')))
|
|
|
|
memmove(ptr, ptr+1, lstrlenW(ptr)*sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (extraPmts == NULL)
|
|
|
|
extraPmts = extraPmtsBuf;
|
|
|
|
}
|
|
|
|
|
2009-07-20 22:03:47 +02:00
|
|
|
/* Now check if there had been a numerical value in the extra params */
|
2009-07-22 04:24:40 +02:00
|
|
|
if ((extraPmts) && (*extraPmts == '@') && (sp == -1)) {
|
2021-09-17 17:16:11 +02:00
|
|
|
sp = wcstol(extraPmts + 1, NULL, 10);
|
2009-07-20 22:03:47 +02:00
|
|
|
}
|
|
|
|
|
2002-12-13 03:17:54 +01:00
|
|
|
TRACE("cmd %s, extra %s, sp %d\n", debugstr_w(buffer), debugstr_w(extraPmts), sp);
|
2002-10-23 20:44:13 +02:00
|
|
|
|
2012-06-05 19:55:27 +02:00
|
|
|
applet = Control_LoadApplet(hWnd, buffer, panel);
|
|
|
|
if (applet)
|
|
|
|
{
|
2008-06-23 19:54:11 +02:00
|
|
|
/* we've been given a textual parameter (or none at all) */
|
|
|
|
if (sp == -1) {
|
|
|
|
while ((++sp) != applet->count) {
|
2012-06-06 11:46:20 +02:00
|
|
|
TRACE("sp %d, name %s\n", sp, debugstr_w(applet->info[sp].name));
|
2008-06-23 19:54:11 +02:00
|
|
|
|
2012-06-06 11:46:20 +02:00
|
|
|
if (StrCmpIW(extraPmts, applet->info[sp].name) == 0)
|
|
|
|
break;
|
2008-06-23 19:54:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sp >= applet->count) {
|
|
|
|
WARN("Out of bounds (%u >= %u), setting to 0\n", sp, applet->count);
|
|
|
|
sp = 0;
|
|
|
|
}
|
|
|
|
|
2012-06-06 11:46:20 +02:00
|
|
|
if (!applet->proc(applet->hWnd, CPL_STARTWPARMSW, sp, (LPARAM)extraPmts))
|
|
|
|
applet->proc(applet->hWnd, CPL_DBLCLK, sp, applet->info[sp].data);
|
2008-06-23 19:54:11 +02:00
|
|
|
|
|
|
|
Control_UnloadApplet(applet);
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
2008-06-23 19:54:11 +02:00
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(buffer);
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2002-12-13 03:17:54 +01:00
|
|
|
* Control_RunDLLW [SHELL32.@]
|
2001-02-23 02:12:26 +01:00
|
|
|
*
|
|
|
|
*/
|
2002-12-13 03:17:54 +01:00
|
|
|
void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow)
|
2001-02-23 02:12:26 +01:00
|
|
|
{
|
|
|
|
CPanel panel;
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p, %p, %s, 0x%08x)\n",
|
2002-12-13 03:17:54 +01:00
|
|
|
hWnd, hInst, debugstr_w(cmd), nCmdShow);
|
2001-02-23 02:12:26 +01:00
|
|
|
|
|
|
|
memset(&panel, 0, sizeof(panel));
|
2012-06-05 19:55:27 +02:00
|
|
|
list_init( &panel.applets );
|
2001-02-23 02:12:26 +01:00
|
|
|
|
|
|
|
if (!cmd || !*cmd) {
|
|
|
|
Control_DoWindow(&panel, hWnd, hInst);
|
|
|
|
} else {
|
|
|
|
Control_DoLaunch(&panel, hWnd, cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-13 03:17:54 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* Control_RunDLLA [SHELL32.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void WINAPI Control_RunDLLA(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)
|
|
|
|
{
|
|
|
|
DWORD len = MultiByteToWideChar(CP_ACP, 0, cmd, -1, NULL, 0 );
|
2018-02-22 08:43:28 +01:00
|
|
|
LPWSTR wszCmd = heap_alloc(len * sizeof(WCHAR));
|
2002-12-13 03:17:54 +01:00
|
|
|
if (wszCmd && MultiByteToWideChar(CP_ACP, 0, cmd, -1, wszCmd, len ))
|
|
|
|
{
|
|
|
|
Control_RunDLLW(hWnd, hInst, wszCmd, nCmdShow);
|
|
|
|
}
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(wszCmd);
|
2002-12-13 03:17:54 +01:00
|
|
|
}
|
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
/*************************************************************************
|
2004-05-27 03:54:30 +02:00
|
|
|
* Control_FillCache_RunDLLW [SHELL32.@]
|
2001-02-23 02:12:26 +01:00
|
|
|
*
|
|
|
|
*/
|
2004-05-27 03:54:30 +02:00
|
|
|
HRESULT WINAPI Control_FillCache_RunDLLW(HWND hWnd, HANDLE hModule, DWORD w, DWORD x)
|
2001-02-23 02:12:26 +01:00
|
|
|
{
|
2006-10-07 20:18:14 +02:00
|
|
|
FIXME("%p %p 0x%08x 0x%08x stub\n", hWnd, hModule, w, x);
|
2012-06-20 09:11:27 +02:00
|
|
|
return S_OK;
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
|
|
|
|
2003-06-16 21:38:10 +02:00
|
|
|
/*************************************************************************
|
2004-05-27 03:54:30 +02:00
|
|
|
* Control_FillCache_RunDLLA [SHELL32.@]
|
2003-06-16 21:38:10 +02:00
|
|
|
*
|
|
|
|
*/
|
2004-05-27 03:54:30 +02:00
|
|
|
HRESULT WINAPI Control_FillCache_RunDLLA(HWND hWnd, HANDLE hModule, DWORD w, DWORD x)
|
2003-06-16 21:38:10 +02:00
|
|
|
{
|
2004-05-27 03:54:30 +02:00
|
|
|
return Control_FillCache_RunDLLW(hWnd, hModule, w, x);
|
2003-06-16 21:38:10 +02:00
|
|
|
}
|
|
|
|
|
2002-01-07 22:16:46 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* CallCPLEntry16 [SHELL32.166]
|
|
|
|
*
|
2001-12-26 21:34:12 +01:00
|
|
|
* called by desk.cpl on "Advanced" with:
|
|
|
|
* hMod("DeskCp16.Dll"), pFunc("CplApplet"), 0, 1, 0xc, 0
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WINAPI CallCPLEntry16(HMODULE hMod, FARPROC pFunc, DWORD dw3, DWORD dw4, DWORD dw5, DWORD dw6)
|
|
|
|
{
|
2006-10-07 20:18:14 +02:00
|
|
|
FIXME("(%p, %p, %08x, %08x, %08x, %08x): stub.\n", hMod, pFunc, dw3, dw4, dw5, dw6);
|
2001-12-26 21:34:12 +01:00
|
|
|
return 0x0deadbee;
|
|
|
|
}
|
2018-02-12 06:11:25 +01:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* RunDLL_CallEntry16 [SHELL32.122]
|
|
|
|
* Manually relay this function to make Tages Protection v5 happy
|
|
|
|
*/
|
|
|
|
void WINAPI RunDLL_CallEntry16( DWORD proc, HWND hwnd, HINSTANCE inst,
|
|
|
|
LPCSTR cmdline, INT cmdshow )
|
|
|
|
{
|
|
|
|
static HMODULE shell16 = NULL;
|
|
|
|
static void (WINAPI *pRunDLL_CallEntry16)( DWORD proc, HWND hwnd, HINSTANCE inst,
|
|
|
|
LPCSTR cmdline, INT cmdshow ) = NULL;
|
|
|
|
|
|
|
|
if (!pRunDLL_CallEntry16)
|
|
|
|
{
|
|
|
|
if (!shell16 && !(shell16 = LoadLibraryA( "shell.dll16" )))
|
|
|
|
return;
|
|
|
|
if (!(pRunDLL_CallEntry16 = (void *)GetProcAddress( shell16, "RunDLL_CallEntry16" )))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pRunDLL_CallEntry16( proc, hwnd, inst, cmdline, cmdshow );
|
|
|
|
}
|