2 * PROJECT: ReactOS System Control Panel Applet
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/sysdm/sysdm.c
5 * PURPOSE: dll entry file
6 * COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org>
14 static LONG APIENTRY
SystemApplet(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
);
15 HINSTANCE hApplet
= 0;
18 APPLET Applets
[NUM_APPLETS
] =
20 {IDI_CPLSYSTEM
, IDS_CPLSYSTEMNAME
, IDS_CPLSYSTEMDESCRIPTION
, SystemApplet
}
23 #define MAX_SYSTEM_PAGES 32
28 IN HINSTANCE hInstance
,
37 LoadStringW(hInstance
, uCaption
, szCaption
, 256);
38 LoadStringW(hInstance
, uText
, szText
, 256);
40 return MessageBoxW(hwnd
,
48 PropSheetAddPage(HPROPSHEETPAGE hpage
, LPARAM lParam
)
50 PROPSHEETHEADER
*ppsh
= (PROPSHEETHEADER
*)lParam
;
51 if (ppsh
!= NULL
&& ppsh
->nPages
< MAX_SYSTEM_PAGES
)
53 ppsh
->phpage
[ppsh
->nPages
++] = hpage
;
61 InitPropSheetPage(PROPSHEETHEADER
*ppsh
, WORD idDlg
, DLGPROC DlgProc
)
66 if (ppsh
->nPages
< MAX_SYSTEM_PAGES
)
68 ZeroMemory(&psp
, sizeof(psp
));
69 psp
.dwSize
= sizeof(psp
);
70 psp
.dwFlags
= PSP_DEFAULT
;
71 psp
.hInstance
= hApplet
;
72 psp
.pszTemplate
= MAKEINTRESOURCE(idDlg
);
73 psp
.pfnDlgProc
= DlgProc
;
75 hPage
= CreatePropertySheetPage(&psp
);
78 return PropSheetAddPage(hPage
, (LPARAM
)ppsh
);
85 typedef HPROPSHEETPAGE (WINAPI
*PCreateNetIDPropertyPage
)(VOID
);
88 AddNetIdPage(PROPSHEETHEADER
*ppsh
)
92 PCreateNetIDPropertyPage pCreateNetIdPage
;
94 hMod
= LoadLibrary(TEXT("netid.dll"));
97 pCreateNetIdPage
= (PCreateNetIDPropertyPage
)GetProcAddress(hMod
,
98 "CreateNetIDPropertyPage");
99 if (pCreateNetIdPage
!= NULL
)
101 hPage
= pCreateNetIdPage();
105 if (!PropSheetAddPage(hPage
, (LPARAM
)ppsh
))
107 DestroyPropertySheetPage(hPage
);
123 PropSheetProc(HWND hwndDlg
, UINT uMsg
, LPARAM lParam
)
125 // NOTE: This callback is needed to set large icon correctly.
129 case PSCB_INITIALIZED
:
131 hIcon
= LoadIconW(hApplet
, MAKEINTRESOURCEW(IDI_CPLSYSTEM
));
132 SendMessageW(hwndDlg
, WM_SETICON
, ICON_BIG
, (LPARAM
)hIcon
);
141 SystemApplet(HWND hwnd
, UINT uMsg
, LPARAM wParam
, LPARAM lParam
)
143 HPROPSHEETPAGE hpsp
[MAX_SYSTEM_PAGES
];
149 static INITCOMMONCONTROLSEX icc
= {sizeof(INITCOMMONCONTROLSEX
), ICC_LINK_CLASS
};
151 if (!InitCommonControlsEx(&icc
))
154 if (uMsg
== CPL_STARTWPARMSW
&& lParam
!= 0)
156 nPage
= _wtoi((PWSTR
)lParam
);
159 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
160 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
161 psh
.dwFlags
= PSH_PROPTITLE
| PSH_USEICONID
| PSH_USECALLBACK
;
162 psh
.hwndParent
= hwnd
;
163 psh
.hInstance
= hApplet
;
164 psh
.pszIcon
= MAKEINTRESOURCEW(IDI_CPLSYSTEM
);
165 psh
.pszCaption
= MAKEINTRESOURCE(IDS_CPLSYSTEMNAME
);
169 psh
.pfnCallback
= PropSheetProc
;
171 InitPropSheetPage(&psh
, IDD_PROPPAGEGENERAL
, GeneralPageProc
);
172 hNetIdDll
= AddNetIdPage(&psh
);
173 InitPropSheetPage(&psh
, IDD_PROPPAGEHARDWARE
, HardwarePageProc
);
174 InitPropSheetPage(&psh
, IDD_PROPPAGEADVANCED
, AdvancedPageProc
);
176 /* Load additional pages provided by shell extensions */
177 hpsxa
= SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE
, REGSTR_PATH_CONTROLSFOLDER
TEXT("\\System"), MAX_SYSTEM_PAGES
- psh
.nPages
);
180 SHAddFromPropSheetExtArray(hpsxa
, PropSheetAddPage
, (LPARAM
)&psh
);
183 if (nPage
!= 0 && nPage
<= psh
.nPages
)
184 psh
.nStartPage
= nPage
;
186 Ret
= (LONG
)(PropertySheet(&psh
) != -1);
190 SHDestroyPropSheetExtArray(hpsxa
);
193 if (hNetIdDll
!= NULL
)
194 FreeLibrary(hNetIdDll
);
199 /* Control Panel Callback */
201 CPlApplet(HWND hwndCPl
,
206 INT i
= (INT
)lParam1
;
208 UNREFERENCED_PARAMETER(hwndCPl
);
220 CPLINFO
*CPlInfo
= (CPLINFO
*)lParam2
;
222 CPlInfo
->idIcon
= Applets
[i
].idIcon
;
223 CPlInfo
->idName
= Applets
[i
].idName
;
224 CPlInfo
->idInfo
= Applets
[i
].idDescription
;
229 Applets
[i
].AppletProc(hwndCPl
, uMsg
, lParam1
, lParam2
);
232 case CPL_STARTWPARMSW
:
233 return Applets
[i
].AppletProc(hwndCPl
, uMsg
, lParam1
, lParam2
);
242 DllMain(HINSTANCE hinstDLL
,
246 UNREFERENCED_PARAMETER(lpvReserved
);
250 case DLL_PROCESS_ATTACH
:
251 case DLL_THREAD_ATTACH
: