📄 control.c
字号:
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 DefWindowProcA(hWnd, wMsg, lParam1, lParam2);
}
static void Control_DoInterface(CPanel* panel, HWND hWnd, HINSTANCE hInst)
{
WNDCLASSA wc;
MSG msg;
const CHAR* appName = "Wine Control Panel";
wc.style = CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc = Control_WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(CPlApplet*);
wc.hInstance = hInst;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "Shell_Control_WndClass";
if (!RegisterClassA(&wc)) return;
CreateWindowExA(0, wc.lpszClassName, appName,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
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 */
MessageBoxA(panel->hWnd, "Cannot load any applets", appName, MB_OK);
return;
}
while (GetMessageA(&msg, panel->hWnd, 0, 0)) {
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
}
static void Control_DoWindow(CPanel* panel, HWND hWnd, HINSTANCE hInst)
{
HANDLE h;
WIN32_FIND_DATAW fd;
WCHAR buffer[MAX_PATH];
static const WCHAR wszAllCpl[] = {'*','.','c','p','l',0};
WCHAR *p;
GetSystemDirectoryW( buffer, MAX_PATH );
p = buffer + strlenW(buffer);
*p++ = '\\';
lstrcpyW(p, wszAllCpl);
if ((h = FindFirstFileW(buffer, &fd)) != INVALID_HANDLE_VALUE) {
do {
lstrcpyW(p, fd.cFileName);
Control_LoadApplet(hWnd, buffer, panel);
} while (FindNextFileW(h, &fd));
FindClose(h);
}
Control_DoInterface(panel, hWnd, hInst);
}
static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
/* forms to parse:
* foo.cpl,@sp,str
* foo.cpl,@sp
* foo.cpl,,str
* foo.cpl @sp
* foo.cpl str
* "a path\foo.cpl"
*/
{
LPWSTR buffer;
LPWSTR beg = NULL;
LPWSTR end;
WCHAR ch;
LPWSTR ptr;
unsigned sp = 0;
LPWSTR extraPmts = NULL;
int quoted = 0;
BOOL spSet = FALSE;
buffer = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(wszCmd) + 1) * sizeof(*wszCmd));
if (!buffer) return;
end = lstrcpyW(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') {
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(ptr, ptr+1, lstrlenW(ptr)*sizeof(WCHAR));
while ((ptr = StrChrW(extraPmts, '"')))
memmove(ptr, ptr+1, lstrlenW(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)&&(!spSet))
{
while ((lstrcmpiW(extraPmts, applet->info[sp].szName)) && (sp < applet->count))
sp++;
}
if (applet->info[sp].dwSize) {
if (!applet->proc(applet->hWnd, CPL_STARTWPARMSA, sp, (LPARAM)extraPmts))
applet->proc(applet->hWnd, CPL_DBLCLK, sp, applet->info[sp].lData);
}
Control_UnloadApplet(applet);
}
HeapFree(GetProcessHeap(), 0, buffer);
}
/*************************************************************************
* Control_RunDLLW [SHELL32.@]
*
*/
void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow)
{
CPanel panel;
TRACE("(%p, %p, %s, 0x%08x)\n",
hWnd, hInst, debugstr_w(cmd), nCmdShow);
memset(&panel, 0, sizeof(panel));
if (!cmd || !*cmd) {
Control_DoWindow(&panel, hWnd, hInst);
} else {
Control_DoLaunch(&panel, hWnd, cmd);
}
}
/*************************************************************************
* 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 );
LPWSTR wszCmd = 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);
}
/*************************************************************************
* Control_FillCache_RunDLLW [SHELL32.@]
*
*/
HRESULT WINAPI Control_FillCache_RunDLLW(HWND hWnd, HANDLE hModule, DWORD w, DWORD x)
{
FIXME("%p %p 0x%08x 0x%08x stub\n", hWnd, hModule, w, x);
return 0;
}
/*************************************************************************
* Control_FillCache_RunDLLA [SHELL32.@]
*
*/
HRESULT WINAPI Control_FillCache_RunDLLA(HWND hWnd, HANDLE hModule, DWORD w, DWORD x)
{
return Control_FillCache_RunDLLW(hWnd, hModule, w, x);
}
/*************************************************************************
* RunDLL_CallEntry16 [SHELL32.122]
* the name is probably wrong
*/
void WINAPI RunDLL_CallEntry16( DWORD proc, HWND hwnd, HINSTANCE inst,
LPCSTR cmdline, INT cmdshow )
{
#if !defined(__CYGWIN__) && !defined (__MINGW32__) && !defined(_MSC_VER)
WORD args[5];
SEGPTR cmdline_seg;
TRACE( "proc %x hwnd %p inst %p cmdline %s cmdshow %d\n",
proc, hwnd, inst, debugstr_a(cmdline), cmdshow );
cmdline_seg = MapLS( cmdline );
args[4] = HWND_16(hwnd);
args[3] = MapHModuleLS(inst);
args[2] = SELECTOROF(cmdline_seg);
args[1] = OFFSETOF(cmdline_seg);
args[0] = cmdshow;
WOWCallback16Ex( proc, WCB16_PASCAL, sizeof(args), args, NULL );
UnMapLS( cmdline_seg );
#else
FIXME( "proc %lx hwnd %p inst %p cmdline %s cmdshow %d\n",
proc, hwnd, inst, debugstr_a(cmdline), cmdshow );
#endif
}
/*************************************************************************
* CallCPLEntry16 [SHELL32.166]
*
* 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)
{
FIXME("(%p, %p, %08x, %08x, %08x, %08x): stub.\n", hMod, pFunc, dw3, dw4, dw5, dw6);
return 0x0deadbee;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -