xref: /reactos/dll/cpl/usrmgr/usrmgr.c (revision e5ebbc8a)
1c2c66affSColin Finck /*
2c2c66affSColin Finck  * COPYRIGHT:       See COPYING in the top level directory
3c2c66affSColin Finck  * PROJECT:         ReactOS User Manager Control Panel
4c2c66affSColin Finck  * FILE:            dll/cpl/usrmgr/usrmgr.c
5c2c66affSColin Finck  * PURPOSE:         Main functions
6c2c66affSColin Finck  *
7c2c66affSColin Finck  * PROGRAMMERS:     Eric Kohl
8c2c66affSColin Finck  */
9c2c66affSColin Finck 
10c2c66affSColin Finck #include "usrmgr.h"
11c2c66affSColin Finck 
12c2c66affSColin Finck #define NUM_APPLETS 1
13c2c66affSColin Finck 
14c2c66affSColin Finck static LONG APIENTRY UsrmgrApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
15c2c66affSColin Finck 
16c2c66affSColin Finck HINSTANCE hApplet = 0;
17c2c66affSColin Finck 
18c2c66affSColin Finck /* Applets */
19c2c66affSColin Finck APPLET Applets[NUM_APPLETS] =
20c2c66affSColin Finck {
21c2c66affSColin Finck     {
22c2c66affSColin Finck         IDI_USRMGR_ICON,
23c2c66affSColin Finck         IDS_CPLNAME,
24c2c66affSColin Finck         IDS_CPLDESCRIPTION,
25c2c66affSColin Finck         UsrmgrApplet
26c2c66affSColin Finck     }
27c2c66affSColin Finck };
28c2c66affSColin Finck 
29c2c66affSColin Finck 
30c2c66affSColin Finck static VOID
31c2c66affSColin Finck InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
32c2c66affSColin Finck {
33c2c66affSColin Finck     ZeroMemory(psp, sizeof(PROPSHEETPAGE));
34c2c66affSColin Finck     psp->dwSize = sizeof(PROPSHEETPAGE);
35c2c66affSColin Finck     psp->dwFlags = PSP_DEFAULT;
36c2c66affSColin Finck     psp->hInstance = hApplet;
37c2c66affSColin Finck     psp->pszTemplate = MAKEINTRESOURCE(idDlg);
38c2c66affSColin Finck     psp->pfnDlgProc = DlgProc;
39c2c66affSColin Finck }
40c2c66affSColin Finck 
41bd55105cSKatayama Hirofumi MZ static int CALLBACK
42bd55105cSKatayama Hirofumi MZ PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
43bd55105cSKatayama Hirofumi MZ {
44bd55105cSKatayama Hirofumi MZ     // NOTE: This callback is needed to set large icon correctly.
45bd55105cSKatayama Hirofumi MZ     HICON hIcon;
46bd55105cSKatayama Hirofumi MZ     switch (uMsg)
47bd55105cSKatayama Hirofumi MZ     {
48bd55105cSKatayama Hirofumi MZ         case PSCB_INITIALIZED:
49bd55105cSKatayama Hirofumi MZ         {
50bd55105cSKatayama Hirofumi MZ             hIcon = LoadIconW(hApplet, MAKEINTRESOURCEW(IDI_USRMGR_ICON));
51bd55105cSKatayama Hirofumi MZ             SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
52bd55105cSKatayama Hirofumi MZ             break;
53bd55105cSKatayama Hirofumi MZ         }
54bd55105cSKatayama Hirofumi MZ     }
55bd55105cSKatayama Hirofumi MZ     return 0;
56bd55105cSKatayama Hirofumi MZ }
57c2c66affSColin Finck 
58c2c66affSColin Finck /* Display Applet */
59c2c66affSColin Finck static LONG APIENTRY
60c2c66affSColin Finck UsrmgrApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
61c2c66affSColin Finck {
624ceea749SJared Smudde     PROPSHEETPAGE psp[2];
63c2c66affSColin Finck     PROPSHEETHEADER psh;
64c2c66affSColin Finck 
65c2c66affSColin Finck     UNREFERENCED_PARAMETER(lParam);
66c2c66affSColin Finck     UNREFERENCED_PARAMETER(wParam);
67c2c66affSColin Finck     UNREFERENCED_PARAMETER(uMsg);
68c2c66affSColin Finck 
69c2c66affSColin Finck     ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
70c2c66affSColin Finck     psh.dwSize = sizeof(PROPSHEETHEADER);
71bd55105cSKatayama Hirofumi MZ     psh.dwFlags =  PSH_PROPSHEETPAGE | PSH_USEICONID | PSH_USECALLBACK;
72c2c66affSColin Finck     psh.hwndParent = hwnd;
73c2c66affSColin Finck     psh.hInstance = hApplet;
74bd55105cSKatayama Hirofumi MZ     psh.pszIcon = MAKEINTRESOURCEW(IDI_USRMGR_ICON);
750c324e35SThamatip Chitpong     psh.pszCaption = MAKEINTRESOURCEW(IDS_CPLNAME);
76c2c66affSColin Finck     psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
77c2c66affSColin Finck     psh.nStartPage = 0;
78c2c66affSColin Finck     psh.ppsp = psp;
79bd55105cSKatayama Hirofumi MZ     psh.pfnCallback = PropSheetProc;
80c2c66affSColin Finck 
81bcbe0dd8SThomas Faber     InitPropSheetPage(&psp[0], IDD_USERS, UsersPageProc);
82bcbe0dd8SThomas Faber     InitPropSheetPage(&psp[1], IDD_GROUPS, GroupsPageProc);
834ceea749SJared Smudde     /* InitPropSheetPage(&psp[2], IDD_EXTRA, ExtraPageProc); */
84c2c66affSColin Finck 
85c2c66affSColin Finck     return (LONG)(PropertySheet(&psh) != -1);
86c2c66affSColin Finck }
87c2c66affSColin Finck 
88c2c66affSColin Finck 
89c2c66affSColin Finck /* Control Panel Callback */
90c2c66affSColin Finck LONG CALLBACK
91c2c66affSColin Finck CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
92c2c66affSColin Finck {
93*e5ebbc8aSKatayama Hirofumi MZ     UINT i = (UINT)lParam1;
94c2c66affSColin Finck 
95c2c66affSColin Finck     switch (uMsg)
96c2c66affSColin Finck     {
97c2c66affSColin Finck         case CPL_INIT:
98c2c66affSColin Finck             return TRUE;
99c2c66affSColin Finck 
100c2c66affSColin Finck         case CPL_GETCOUNT:
101c2c66affSColin Finck             return NUM_APPLETS;
102c2c66affSColin Finck 
103c2c66affSColin Finck         case CPL_INQUIRE:
104*e5ebbc8aSKatayama Hirofumi MZ             if (i < NUM_APPLETS)
105c2c66affSColin Finck             {
106c2c66affSColin Finck                 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
107c2c66affSColin Finck                 CPlInfo->lData = 0;
108c2c66affSColin Finck                 CPlInfo->idIcon = Applets[i].idIcon;
109c2c66affSColin Finck                 CPlInfo->idName = Applets[i].idName;
110c2c66affSColin Finck                 CPlInfo->idInfo = Applets[i].idDescription;
111c2c66affSColin Finck             }
112*e5ebbc8aSKatayama Hirofumi MZ             else
113*e5ebbc8aSKatayama Hirofumi MZ             {
114*e5ebbc8aSKatayama Hirofumi MZ                 return TRUE;
115*e5ebbc8aSKatayama Hirofumi MZ             }
116c2c66affSColin Finck             break;
117c2c66affSColin Finck 
118c2c66affSColin Finck         case CPL_DBLCLK:
119*e5ebbc8aSKatayama Hirofumi MZ             if (i < NUM_APPLETS)
120c2c66affSColin Finck                 Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
121*e5ebbc8aSKatayama Hirofumi MZ             else
122*e5ebbc8aSKatayama Hirofumi MZ                 return TRUE;
123c2c66affSColin Finck             break;
124c2c66affSColin Finck     }
125c2c66affSColin Finck 
126c2c66affSColin Finck     return FALSE;
127c2c66affSColin Finck }
128c2c66affSColin Finck 
129c2c66affSColin Finck 
130c2c66affSColin Finck BOOL WINAPI
131c2c66affSColin Finck DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
132c2c66affSColin Finck {
133c2c66affSColin Finck     UNREFERENCED_PARAMETER(lpvReserved);
134c2c66affSColin Finck 
135c2c66affSColin Finck     switch (dwReason)
136c2c66affSColin Finck     {
137c2c66affSColin Finck         case DLL_PROCESS_ATTACH:
138c2c66affSColin Finck             hApplet = hinstDLL;
139c2c66affSColin Finck             break;
140c2c66affSColin Finck     }
141c2c66affSColin Finck 
142c2c66affSColin Finck     return TRUE;
143c2c66affSColin Finck }
144