[INTL] Implement the selection of a property page by command line

This commit is contained in:
Eric Kohl 2020-12-20 10:47:08 +01:00
parent 97cf947919
commit 497fe0a884

View file

@ -36,7 +36,6 @@ Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
HINSTANCE hApplet = 0; HINSTANCE hApplet = 0;
HWND hCPLWindow;
HINF hSetupInf = INVALID_HANDLE_VALUE; HINF hSetupInf = INVALID_HANDLE_VALUE;
DWORD IsUnattendedSetupEnabled = 0; DWORD IsUnattendedSetupEnabled = 0;
DWORD UnattendLCID = 0; DWORD UnattendLCID = 0;
@ -173,6 +172,7 @@ Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
PROPSHEETPAGE psp[3]; PROPSHEETPAGE psp[3];
PROPSHEETHEADER psh; PROPSHEETHEADER psh;
PGLOBALDATA pGlobalData; PGLOBALDATA pGlobalData;
INT nPage = 0;
LONG ret; LONG ret;
if (OpenSetupInf()) if (OpenSetupInf())
@ -180,6 +180,9 @@ Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
ParseSetupInf(); ParseSetupInf();
} }
if (uMsg == CPL_STARTWPARMSW && lParam != 0)
nPage = _wtoi((PWSTR)lParam);
pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBALDATA)); pGlobalData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLOBALDATA));
if (pGlobalData == NULL) if (pGlobalData == NULL)
return FALSE; return FALSE;
@ -192,11 +195,11 @@ Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK; psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
psh.hwndParent = hCPLWindow; psh.hwndParent = hwnd;
psh.hInstance = hApplet; psh.hInstance = hApplet;
psh.pszIcon = MAKEINTRESOURCEW(IDC_CPLICON); psh.pszIcon = MAKEINTRESOURCEW(IDC_CPLICON);
psh.pszCaption = Caption; psh.pszCaption = Caption;
psh.nPages = 0; //sizeof(psp) / sizeof(PROPSHEETPAGE); psh.nPages = 0;
psh.nStartPage = 0; psh.nStartPage = 0;
psh.ppsp = psp; psh.ppsp = psp;
psh.pfnCallback = PropSheetProc; psh.pfnCallback = PropSheetProc;
@ -212,6 +215,9 @@ Applet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
psh.nPages++; psh.nPages++;
} }
if (nPage != 0 && nPage <= psh.nPages)
psh.nStartPage = nPage;
ret = (LONG)(PropertySheet(&psh) != -1); ret = (LONG)(PropertySheet(&psh) != -1);
HeapFree(GetProcessHeap(), 0, pGlobalData); HeapFree(GetProcessHeap(), 0, pGlobalData);
@ -227,7 +233,7 @@ CPlApplet(HWND hwndCpl,
LPARAM lParam1, LPARAM lParam1,
LPARAM lParam2) LPARAM lParam2)
{ {
switch(uMsg) switch (uMsg)
{ {
case CPL_INIT: case CPL_INIT:
return TRUE; return TRUE;
@ -248,12 +254,11 @@ CPlApplet(HWND hwndCpl,
} }
case CPL_DBLCLK: case CPL_DBLCLK:
{ Applets[(UINT)lParam1].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
UINT uAppIndex = (UINT)lParam1;
hCPLWindow = hwndCpl;
Applets[uAppIndex].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
break; break;
}
case CPL_STARTWPARMSW:
return Applets[(UINT)lParam1].AppletProc(hwndCpl, uMsg, lParam1, lParam2);
} }
return FALSE; return FALSE;