[SYSDM]
[reactos.git] / reactos / dll / cpl / usrmgr / usrmgr.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS User Manager Control Panel
5 * FILE: dll/cpl/usrmgr/usrmgr.c
6 * PURPOSE: Main functions
7 *
8 * PROGRAMMERS: Eric Kohl
9 */
10
11 #include "usrmgr.h"
12
13 #define NUM_APPLETS 1
14
15 static LONG APIENTRY UsrmgrApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
16
17 HINSTANCE hApplet = 0;
18
19 /* Applets */
20 APPLET Applets[NUM_APPLETS] =
21 {
22 {
23 IDI_USRMGR_ICON,
24 IDS_CPLNAME,
25 IDS_CPLDESCRIPTION,
26 UsrmgrApplet
27 }
28 };
29
30
31 static VOID
32 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
33 {
34 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
35 psp->dwSize = sizeof(PROPSHEETPAGE);
36 psp->dwFlags = PSP_DEFAULT;
37 psp->hInstance = hApplet;
38 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
39 psp->pfnDlgProc = DlgProc;
40 }
41
42
43 /* Display Applet */
44 static LONG APIENTRY
45 UsrmgrApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
46 {
47 PROPSHEETPAGE psp[3];
48 PROPSHEETHEADER psh;
49 TCHAR Caption[1024];
50
51 UNREFERENCED_PARAMETER(lParam);
52 UNREFERENCED_PARAMETER(wParam);
53 UNREFERENCED_PARAMETER(uMsg);
54
55 LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
56
57 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
58 psh.dwSize = sizeof(PROPSHEETHEADER);
59 psh.dwFlags = PSH_PROPSHEETPAGE;
60 psh.hwndParent = hwnd;
61 psh.hInstance = hApplet;
62 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_USRMGR_ICON));
63 psh.pszCaption = Caption;
64 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
65 psh.nStartPage = 0;
66 psh.ppsp = psp;
67
68 InitPropSheetPage(&psp[0], IDD_USERS, (DLGPROC)UsersPageProc);
69 InitPropSheetPage(&psp[1], IDD_GROUPS, (DLGPROC)GroupsPageProc);
70 InitPropSheetPage(&psp[2], IDD_EXTRA, (DLGPROC)ExtraPageProc);
71
72 return (LONG)(PropertySheet(&psh) != -1);
73 }
74
75
76 /* Control Panel Callback */
77 LONG CALLBACK
78 CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
79 {
80 int i = (int)lParam1;
81
82 switch (uMsg)
83 {
84 case CPL_INIT:
85 return TRUE;
86
87 case CPL_GETCOUNT:
88 return NUM_APPLETS;
89
90 case CPL_INQUIRE:
91 {
92 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
93 CPlInfo->lData = 0;
94 CPlInfo->idIcon = Applets[i].idIcon;
95 CPlInfo->idName = Applets[i].idName;
96 CPlInfo->idInfo = Applets[i].idDescription;
97 }
98 break;
99
100 case CPL_DBLCLK:
101 Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
102 break;
103 }
104
105 return FALSE;
106 }
107
108
109 BOOL WINAPI
110 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
111 {
112 UNREFERENCED_PARAMETER(lpvReserved);
113
114 switch (dwReason)
115 {
116 case DLL_PROCESS_ATTACH:
117 hApplet = hinstDLL;
118 break;
119 }
120
121 return TRUE;
122 }