[SYSDM] Implement the selection of a property page by command line
authorEric Kohl <eric.kohl@reactos.org>
Sun, 9 Feb 2020 12:07:13 +0000 (13:07 +0100)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 9 Feb 2020 12:07:13 +0000 (13:07 +0100)
dll/cpl/sysdm/precomp.h
dll/cpl/sysdm/sysdm.c

index 5eb6660..0e6fbde 100644 (file)
 #include <shellapi.h>
 #include <shlobj.h>
 #include <setupapi.h>
+#include <cpl.h>
 
 #include "resource.h"
 
 #define NUM_APPLETS (1)
 
-typedef LONG (CALLBACK *APPLET_INITPROC)(VOID);
-
 typedef struct _APPLET
 {
   int idIcon;
   int idName;
   int idDescription;
-  APPLET_INITPROC AppletProc;
+  APPLET_PROC AppletProc;
 } APPLET, *PAPPLET;
 
 extern HINSTANCE hApplet;
index 8061b1c..817c001 100644 (file)
@@ -9,12 +9,10 @@
 
 #include "precomp.h"
 
-#include <cpl.h>
 #include <regstr.h>
 
-LONG CALLBACK SystemApplet(VOID);
+static LONG APIENTRY SystemApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
 HINSTANCE hApplet = 0;
-HWND hCPLWindow;
 
 /* Applets */
 APPLET Applets[NUM_APPLETS] =
@@ -140,22 +138,28 @@ PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
 
 /* First Applet */
 LONG CALLBACK
-SystemApplet(VOID)
+SystemApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
 {
     HPROPSHEETPAGE hpsp[MAX_SYSTEM_PAGES];
     PROPSHEETHEADER psh;
     HMODULE hNetIdDll;
     HPSXA hpsxa = NULL;
+    INT nPage = 0;
     LONG Ret;
     static INITCOMMONCONTROLSEX icc = {sizeof(INITCOMMONCONTROLSEX), ICC_LINK_CLASS};
 
     if (!InitCommonControlsEx(&icc))
         return 0;
 
+    if (uMsg == CPL_STARTWPARMSW && lParam != 0)
+    {
+        nPage = _wtoi((PWSTR)lParam);
+    }
+
     ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
     psh.dwSize = sizeof(PROPSHEETHEADER);
     psh.dwFlags =  PSH_PROPTITLE | PSH_USEICONID | PSH_USECALLBACK;
-    psh.hwndParent = hCPLWindow;
+    psh.hwndParent = hwnd;
     psh.hInstance = hApplet;
     psh.pszIcon = MAKEINTRESOURCEW(IDI_USERPROF);
     psh.pszCaption = MAKEINTRESOURCE(IDS_CPLSYSTEMNAME);
@@ -176,6 +180,9 @@ SystemApplet(VOID)
         SHAddFromPropSheetExtArray(hpsxa, PropSheetAddPage, (LPARAM)&psh);
     }
 
+    if (nPage != 0 && nPage <= psh.nPages)
+        psh.nStartPage = nPage;
+
     Ret = (LONG)(PropertySheet(&psh) != -1);
 
     if (hpsxa != NULL)
@@ -219,9 +226,12 @@ CPlApplet(HWND hwndCPl,
             break;
 
         case CPL_DBLCLK:
-            hCPLWindow = hwndCPl;
-            Applets[i].AppletProc();
+            Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
             break;
+
+        case CPL_STARTWPARMSW:
+            return Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
+
     }
 
     return FALSE;