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 UINT i = (UINT)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 if (i < NUM_APPLETS) 105 { 106 CPLINFO *CPlInfo = (CPLINFO*)lParam2; 107 CPlInfo->lData = 0; 108 CPlInfo->idIcon = Applets[i].idIcon; 109 CPlInfo->idName = Applets[i].idName; 110 CPlInfo->idInfo = Applets[i].idDescription; 111 } 112 else 113 { 114 return TRUE; 115 } 116 break; 117 118 case CPL_DBLCLK: 119 if (i < NUM_APPLETS) 120 Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2); 121 else 122 return TRUE; 123 break; 124 } 125 126 return FALSE; 127 } 128 129 130 BOOL WINAPI 131 DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved) 132 { 133 UNREFERENCED_PARAMETER(lpvReserved); 134 135 switch (dwReason) 136 { 137 case DLL_PROCESS_ATTACH: 138 hApplet = hinstDLL; 139 break; 140 } 141 142 return TRUE; 143 } 144