/*
- * ReactOS
- * Copyright (C) 2004 ReactOS Team
+ * PROJECT: ReactOS System Control Panel Applet
+ * LICENSE: GPL - See COPYING in the top level directory
+ * FILE: dll/cpl/sysdm/sysdm.c
+ * PURPOSE: dll entry file
+ * COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/* $Id$
- *
- * PROJECT: ReactOS System Control Panel
- * FILE: lib/cpl/system/sysdm.c
- * PURPOSE: ReactOS System Control Panel
- * PROGRAMMER: Thomas Weidenmueller (w3seek@users.sourceforge.net)
- * UPDATE HISTORY:
- * 03-04-2004 Created
*/
-#include <windows.h>
-#include <commctrl.h>
-#include <prsht.h>
-#include <cpl.h>
-#include <stdlib.h>
-#include "resource.h"
-#include "sysdm.h"
-
-#define NUM_APPLETS (1)
+#include "precomp.h"
LONG CALLBACK SystemApplet(VOID);
HINSTANCE hApplet = 0;
+HWND hCPLWindow;
/* Applets */
-APPLET Applets[NUM_APPLETS] =
+APPLET Applets[NUM_APPLETS] =
{
- {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
+ {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
};
-static void
-InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
+#define MAX_SYSTEM_PAGES 32
+
+static BOOL CALLBACK
+PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
{
- ZeroMemory(psp, sizeof(PROPSHEETPAGE));
- psp->dwSize = sizeof(PROPSHEETPAGE);
- psp->dwFlags = PSP_DEFAULT;
- psp->hInstance = hApplet;
- psp->pszTemplate = MAKEINTRESOURCE(idDlg);
- psp->pfnDlgProc = DlgProc;
+ PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam;
+ if (ppsh != NULL && ppsh->nPages < MAX_SYSTEM_PAGES)
+ {
+ ppsh->phpage[ppsh->nPages++] = hpage;
+ return TRUE;
+ }
+
+ return FALSE;
}
-/* Property Sheet Callback */
-int CALLBACK
-PropSheetProc(
- HWND hwndDlg,
- UINT uMsg,
- LPARAM lParam
-)
+static BOOL
+InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc)
{
- UNREFERENCED_PARAMETER(hwndDlg)
- switch(uMsg)
- {
- case PSCB_BUTTONPRESSED:
- switch(lParam)
- {
- case PSBTN_OK: /* OK */
- break;
- case PSBTN_CANCEL: /* Cancel */
- break;
- case PSBTN_APPLYNOW: /* Apply now */
- break;
- case PSBTN_FINISH: /* Close */
- break;
- default:
- return FALSE;
- }
- break;
-
- case PSCB_INITIALIZED:
- break;
- }
- return TRUE;
+ HPROPSHEETPAGE hPage;
+ PROPSHEETPAGE psp;
+
+ if (ppsh->nPages < MAX_SYSTEM_PAGES)
+ {
+ ZeroMemory(&psp, sizeof(psp));
+ psp.dwSize = sizeof(psp);
+ psp.dwFlags = PSP_DEFAULT;
+ psp.hInstance = hApplet;
+ psp.pszTemplate = MAKEINTRESOURCE(idDlg);
+ psp.pfnDlgProc = DlgProc;
+
+ hPage = CreatePropertySheetPage(&psp);
+ if (hPage != NULL)
+ {
+ return PropSheetAddPage(hPage, (LPARAM)ppsh);
+ }
+ }
+
+ return FALSE;
}
-/* First Applet */
+typedef HPROPSHEETPAGE (WINAPI *PCreateNetIDPropertyPage)(VOID);
-LONG CALLBACK
-SystemApplet(VOID)
+static HMODULE
+AddNetIdPage(PROPSHEETHEADER *ppsh)
{
- PROPSHEETPAGE psp[5];
- PROPSHEETHEADER psh;
- TCHAR Caption[1024];
-
- LoadString(hApplet, IDS_CPLSYSTEMNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
-
- ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
- psh.dwSize = sizeof(PROPSHEETHEADER);
- psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE; /* | PSH_USECALLBACK */
- psh.hwndParent = NULL;
- psh.hInstance = hApplet;
- psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
- psh.pszCaption = Caption;
- psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
- psh.nStartPage = 0;
- psh.ppsp = psp;
- psh.pfnCallback = NULL; /* PropSheetProc; */
-
- InitPropSheetPage(&psp[0], IDD_PROPPAGEGENERAL, (DLGPROC) GeneralPageProc);
- InitPropSheetPage(&psp[1], IDD_PROPPAGECOMPUTER, (DLGPROC) ComputerPageProc);
- InitPropSheetPage(&psp[2], IDD_PROPPAGEHARDWARE, (DLGPROC) HardwarePageProc);
- InitPropSheetPage(&psp[3], IDD_PROPPAGEUSERPROFILE, (DLGPROC) UserProfilePageProc);
- InitPropSheetPage(&psp[4], IDD_PROPPAGEADVANCED, (DLGPROC) AdvancedPageProc);
-
- return (LONG)(PropertySheet(&psh) != -1);
+ HPROPSHEETPAGE hPage;
+ HMODULE hMod;
+ PCreateNetIDPropertyPage pCreateNetIdPage;
+
+ hMod = LoadLibrary(TEXT("netid.dll"));
+ if (hMod != NULL)
+ {
+ pCreateNetIdPage = (PCreateNetIDPropertyPage)GetProcAddress(hMod,
+ "CreateNetIDPropertyPage");
+ if (pCreateNetIdPage != NULL)
+ {
+ hPage = pCreateNetIdPage();
+ if (hPage == NULL)
+ goto Fail;
+
+ if (!PropSheetAddPage(hPage, (LPARAM)ppsh))
+ {
+ DestroyPropertySheetPage(hPage);
+ goto Fail;
+ }
+ }
+ else
+ {
+Fail:
+ FreeLibrary(hMod);
+ hMod = NULL;
+ }
+ }
+
+ return hMod;
}
-/* Control Panel Callback */
+/* First Applet */
LONG CALLBACK
-CPlApplet(
- HWND hwndCPl,
- UINT uMsg,
- LPARAM lParam1,
- LPARAM lParam2)
+SystemApplet(VOID)
{
- int i = (int)lParam1;
- UNREFERENCED_PARAMETER(hwndCPl)
+ HPROPSHEETPAGE hpsp[MAX_SYSTEM_PAGES];
+ PROPSHEETHEADER psh;
+ HMODULE hNetIdDll;
+ HPSXA hpsxa = NULL;
+ LONG Ret;
+ static INITCOMMONCONTROLSEX icc = {sizeof(INITCOMMONCONTROLSEX), ICC_LINK_CLASS};
- switch(uMsg)
- {
- case CPL_INIT:
- {
- return TRUE;
- }
- case CPL_GETCOUNT:
+ if (!InitCommonControlsEx(&icc))
+ return 0;
+
+ ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
+ psh.dwSize = sizeof(PROPSHEETHEADER);
+ psh.dwFlags = PSH_PROPTITLE;
+ psh.hwndParent = hCPLWindow;
+ psh.hInstance = hApplet;
+ psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
+ psh.pszCaption = MAKEINTRESOURCE(IDS_CPLSYSTEMNAME);
+ psh.nPages = 0;
+ psh.nStartPage = 0;
+ psh.phpage = hpsp;
+ psh.pfnCallback = NULL;
+
+ InitPropSheetPage(&psh, IDD_PROPPAGEGENERAL, (DLGPROC) GeneralPageProc);
+ hNetIdDll = AddNetIdPage(&psh);
+ InitPropSheetPage(&psh, IDD_PROPPAGEHARDWARE, (DLGPROC) HardwarePageProc);
+ InitPropSheetPage(&psh, IDD_PROPPAGEADVANCED, (DLGPROC) AdvancedPageProc);
+
+ /* Load additional pages provided by shell extensions */
+ hpsxa = SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\System"), MAX_SYSTEM_PAGES - psh.nPages);
+ if (hpsxa != NULL)
{
- return NUM_APPLETS;
+ SHAddFromPropSheetExtArray(hpsxa, PropSheetAddPage, (LPARAM)&psh);
}
- case CPL_INQUIRE:
+
+ Ret = (LONG)(PropertySheet(&psh) != -1);
+
+ if (hpsxa != NULL)
{
- CPLINFO *CPlInfo = (CPLINFO*)lParam2;
- CPlInfo->lData = 0;
- CPlInfo->idIcon = Applets[i].idIcon;
- CPlInfo->idName = Applets[i].idName;
- CPlInfo->idInfo = Applets[i].idDescription;
- break;
+ SHDestroyPropSheetExtArray(hpsxa);
}
- case CPL_DBLCLK:
+
+ if (hNetIdDll != NULL)
+ FreeLibrary(hNetIdDll);
+
+ return Ret;
+}
+
+/* Control Panel Callback */
+LONG CALLBACK
+CPlApplet(HWND hwndCPl,
+ UINT uMsg,
+ LPARAM lParam1,
+ LPARAM lParam2)
+{
+ INT i = (INT)lParam1;
+
+ UNREFERENCED_PARAMETER(hwndCPl);
+
+ switch (uMsg)
{
- Applets[i].AppletProc();
- break;
+ case CPL_INIT:
+ return TRUE;
+
+ case CPL_GETCOUNT:
+ return NUM_APPLETS;
+
+ case CPL_INQUIRE:
+ {
+ CPLINFO *CPlInfo = (CPLINFO*)lParam2;
+ CPlInfo->lData = 0;
+ CPlInfo->idIcon = Applets[i].idIcon;
+ CPlInfo->idName = Applets[i].idName;
+ CPlInfo->idInfo = Applets[i].idDescription;
+ }
+ break;
+
+ case CPL_DBLCLK:
+ hCPLWindow = hwndCPl;
+ Applets[i].AppletProc();
+ break;
}
- }
- return FALSE;
+
+ return FALSE;
}
-BOOL STDCALL
-DllMain(
- HINSTANCE hinstDLL,
- DWORD dwReason,
- LPVOID lpvReserved)
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL,
+ DWORD dwReason,
+ LPVOID lpvReserved)
{
- UNREFERENCED_PARAMETER(lpvReserved)
- switch(dwReason)
- {
- case DLL_PROCESS_ATTACH:
- case DLL_THREAD_ATTACH:
- hApplet = hinstDLL;
- break;
- }
- return TRUE;
-}
+ UNREFERENCED_PARAMETER(lpvReserved);
+
+ switch (dwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ hApplet = hinstDLL;
+ break;
+ }
+ return TRUE;
+}