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