fc7c652a3bb6ecb7c9aaae3dfee9dec1cd45d286
[reactos.git] / reactos / dll / cpl / usrmgr / userprops.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS User Manager Control Panel
4 * FILE: dll/cpl/usrmgr/userprops.c
5 * PURPOSE: User property sheet
6 *
7 * PROGRAMMERS: Eric Kohl
8 */
9
10 #include "usrmgr.h"
11
12 typedef struct _GENERAL_USER_DATA
13 {
14 DWORD dwFlags;
15 DWORD dwPasswordExpired;
16 TCHAR szUserName[1];
17 } GENERAL_USER_DATA, *PGENERAL_USER_DATA;
18
19 #define VALID_GENERAL_FLAGS (UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD | UF_ACCOUNTDISABLE | UF_LOCKOUT)
20
21 typedef struct _PROFILE_USER_DATA
22 {
23 TCHAR szUserName[1];
24 } PROFILE_USER_DATA, *PPROFILE_USER_DATA;
25
26
27
28 static VOID
29 GetUserProfileData(HWND hwndDlg,
30 PPROFILE_USER_DATA pUserData)
31 {
32 PUSER_INFO_3 userInfo = NULL;
33 NET_API_STATUS status;
34 BOOL bLocal;
35 TCHAR szDrive[8];
36 INT i;
37 INT nSel;
38
39 status = NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&userInfo);
40 if (status != NERR_Success)
41 return;
42
43 SetDlgItemText(hwndDlg, IDC_USER_PROFILE_PATH, userInfo->usri3_profile);
44 SetDlgItemText(hwndDlg, IDC_USER_PROFILE_SCRIPT, userInfo->usri3_script_path);
45
46
47 bLocal = (userInfo->usri3_home_dir_drive == NULL) ||
48 (_tcslen(userInfo->usri3_home_dir_drive) == 0);
49 CheckRadioButton(hwndDlg, IDC_USER_PROFILE_LOCAL, IDC_USER_PROFILE_REMOTE,
50 bLocal ? IDC_USER_PROFILE_LOCAL : IDC_USER_PROFILE_REMOTE);
51
52 for (i = 0; i < 26; i++)
53 {
54 wsprintf(szDrive, _T("%c:"), (TCHAR)('A' + i));
55 nSel = SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE),
56 CB_INSERTSTRING, -1, (LPARAM)szDrive);
57 }
58
59 if (bLocal)
60 {
61 SetDlgItemText(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH, userInfo->usri3_home_dir);
62 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), FALSE);
63 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH), FALSE);
64 }
65 else
66 {
67 SetDlgItemText(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH, userInfo->usri3_home_dir);
68 nSel = SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE),
69 CB_FINDSTRINGEXACT, -1, (LPARAM)userInfo->usri3_home_dir_drive);
70 }
71
72 SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE),
73 CB_SETCURSEL, nSel, 0);
74
75 NetApiBufferFree(userInfo);
76 }
77
78
79 static BOOL
80 SetUserProfileData(HWND hwndDlg,
81 PPROFILE_USER_DATA pUserData)
82 {
83 PUSER_INFO_3 pUserInfo = NULL;
84 LPTSTR pszProfilePath = NULL;
85 LPTSTR pszScriptPath = NULL;
86 LPTSTR pszHomeDir = NULL;
87 LPTSTR pszHomeDrive = NULL;
88 NET_API_STATUS status;
89 #if 0
90 DWORD dwIndex;
91 #endif
92 INT nLength;
93 INT nIndex;
94
95 NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&pUserInfo);
96
97 /* Get the profile path */
98 nLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_USER_PROFILE_PATH));
99 if (nLength == 0)
100 {
101 pUserInfo->usri3_profile = NULL;
102 }
103 else
104 {
105 pszProfilePath = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
106 GetDlgItemText(hwndDlg, IDC_USER_PROFILE_PATH, pszProfilePath, nLength + 1);
107 pUserInfo->usri3_profile = pszProfilePath;
108 }
109
110 /* Get the script path */
111 nLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_USER_PROFILE_SCRIPT));
112 if (nLength == 0)
113 {
114 pUserInfo->usri3_script_path = NULL;
115 }
116 else
117 {
118 pszScriptPath = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
119 GetDlgItemText(hwndDlg, IDC_USER_PROFILE_SCRIPT, pszScriptPath, nLength + 1);
120 pUserInfo->usri3_script_path = pszScriptPath;
121 }
122
123 if (IsDlgButtonChecked(hwndDlg, IDC_USER_PROFILE_LOCAL) == BST_CHECKED)
124 {
125 /* Local home directory */
126 nLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH));
127 if (nLength == 0)
128 {
129 pUserInfo->usri3_home_dir = NULL;
130 }
131 else
132 {
133 pszHomeDir = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
134 GetDlgItemText(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH, pszHomeDir, nLength + 1);
135 pUserInfo->usri3_home_dir = pszHomeDir;
136 }
137 }
138 else
139 {
140 /* Remote home directory */
141 nLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH));
142 if (nLength == 0)
143 {
144 pUserInfo->usri3_home_dir = NULL;
145 }
146 else
147 {
148 pszHomeDir = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
149 GetDlgItemText(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH, pszHomeDir, nLength + 1);
150 pUserInfo->usri3_home_dir = pszHomeDir;
151 }
152
153 nIndex = SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), CB_GETCURSEL, 0, 0);
154 if (nIndex != CB_ERR)
155 {
156 nLength = SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), CB_GETLBTEXTLEN, nIndex, 0);
157 pszHomeDrive = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
158 SendMessage(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), CB_GETLBTEXT, nIndex, (LPARAM)pszHomeDrive);
159 pUserInfo->usri3_home_dir_drive = pszHomeDrive;
160 }
161 }
162
163 #if 0
164 status = NetUserSetInfo(NULL, pUserData->szUserName, 3, (LPBYTE)pUserInfo, &dwIndex);
165 if (status != NERR_Success)
166 {
167 DebugPrintf(_T("Status: %lu Index: %lu"), status, dwIndex);
168 }
169 #else
170 status = NERR_Success;
171 #endif
172
173 if (pszProfilePath)
174 HeapFree(GetProcessHeap(), 0, pszProfilePath);
175
176 if (pszScriptPath)
177 HeapFree(GetProcessHeap(), 0, pszScriptPath);
178
179 if (pszHomeDir)
180 HeapFree(GetProcessHeap(), 0, pszHomeDir);
181
182 if (pszHomeDrive)
183 HeapFree(GetProcessHeap(), 0, pszHomeDrive);
184
185 NetApiBufferFree(pUserInfo);
186
187 return (status == NERR_Success);
188 }
189
190
191 INT_PTR CALLBACK
192 UserProfilePageProc(HWND hwndDlg,
193 UINT uMsg,
194 WPARAM wParam,
195 LPARAM lParam)
196 {
197 PPROFILE_USER_DATA pUserData;
198
199 UNREFERENCED_PARAMETER(lParam);
200 UNREFERENCED_PARAMETER(wParam);
201 UNREFERENCED_PARAMETER(hwndDlg);
202
203 pUserData= (PPROFILE_USER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
204
205 switch (uMsg)
206 {
207 case WM_INITDIALOG:
208 pUserData = (PPROFILE_USER_DATA)HeapAlloc(GetProcessHeap(),
209 HEAP_ZERO_MEMORY,
210 sizeof(PROFILE_USER_DATA) +
211 lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
212 lstrcpy(pUserData->szUserName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
213
214 SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
215
216 GetUserProfileData(hwndDlg,
217 pUserData);
218 break;
219
220 case WM_COMMAND:
221 switch (LOWORD(wParam))
222 {
223 case IDC_USER_PROFILE_PATH:
224 case IDC_USER_PROFILE_SCRIPT:
225 if (HIWORD(wParam) == EN_CHANGE)
226 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
227 break;
228
229 case IDC_USER_PROFILE_LOCAL:
230 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH), TRUE);
231 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), FALSE);
232 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH), FALSE);
233 break;
234
235 case IDC_USER_PROFILE_REMOTE:
236 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_LOCAL_PATH), FALSE);
237 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_DRIVE), TRUE);
238 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_PROFILE_REMOTE_PATH), TRUE);
239 break;
240 }
241 break;
242
243 case WM_DESTROY:
244 HeapFree(GetProcessHeap(), 0, pUserData);
245 break;
246
247 case WM_NOTIFY:
248 if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
249 {
250 SetUserProfileData(hwndDlg, pUserData);
251 return TRUE;
252 }
253 break;
254 }
255
256 return FALSE;
257 }
258
259
260 static VOID
261 GetMembershipData(HWND hwndDlg, LPTSTR lpUserName)
262 {
263 PLOCALGROUP_USERS_INFO_0 usersInfo = NULL;
264 NET_API_STATUS status;
265 DWORD dwRead;
266 DWORD dwTotal;
267 DWORD i;
268 HIMAGELIST hImgList;
269 HICON hIcon;
270 LV_ITEM lvi;
271 HWND hwndLV;
272 LV_COLUMN column;
273 RECT rect;
274
275
276 hwndLV = GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_LIST);
277
278 /* Create the image list */
279 hImgList = ImageList_Create(16, 16, ILC_COLOR8 | ILC_MASK, 5, 5);
280 hIcon = LoadImage(hApplet, MAKEINTRESOURCE(IDI_GROUP), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
281 ImageList_AddIcon(hImgList, hIcon);
282 DestroyIcon(hIcon);
283 (void)ListView_SetImageList(hwndLV, hImgList, LVSIL_SMALL);
284
285 /* Set the list column */
286 GetClientRect(hwndLV, &rect);
287
288 memset(&column, 0x00, sizeof(column));
289 column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
290 column.fmt = LVCFMT_LEFT;
291 column.cx = (INT)(rect.right - rect.left);
292 column.iSubItem = 0;
293 (void)ListView_InsertColumn(hwndLV, 0, &column);
294
295
296 status = NetUserGetLocalGroups(NULL, lpUserName, 0, 0,
297 (LPBYTE*)&usersInfo,
298 MAX_PREFERRED_LENGTH,
299 &dwRead,
300 &dwTotal);
301 if (status != NERR_Success)
302 return;
303
304 for (i = 0; i < dwRead; i++)
305 {
306 ZeroMemory(&lvi, sizeof(lvi));
307 lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
308 lvi.pszText = usersInfo[i].lgrui0_name;
309 lvi.state = 0;
310 lvi.iImage = 0;
311
312 (void)ListView_InsertItem(hwndLV, &lvi);
313 }
314
315
316 NetApiBufferFree(usersInfo);
317
318 }
319
320
321 INT_PTR CALLBACK
322 UserMembershipPageProc(HWND hwndDlg,
323 UINT uMsg,
324 WPARAM wParam,
325 LPARAM lParam)
326 {
327
328 UNREFERENCED_PARAMETER(lParam);
329 UNREFERENCED_PARAMETER(wParam);
330 UNREFERENCED_PARAMETER(hwndDlg);
331
332 switch (uMsg)
333 {
334 case WM_INITDIALOG:
335 GetMembershipData(hwndDlg,
336 (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
337 break;
338
339 }
340
341 return FALSE;
342 }
343
344
345 static VOID
346 UpdateUserOptions(HWND hwndDlg,
347 PGENERAL_USER_DATA pUserData,
348 BOOL bInit)
349 {
350 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_CANNOT_CHANGE),
351 !pUserData->dwPasswordExpired);
352 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_NEVER_EXPIRES),
353 !pUserData->dwPasswordExpired);
354 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_FORCE_CHANGE),
355 (pUserData->dwFlags & (UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD)) == 0);
356
357 EnableWindow(GetDlgItem(hwndDlg, IDC_USER_GENERAL_LOCKED),
358 (pUserData->dwFlags & UF_LOCKOUT) != 0);
359
360 if (bInit)
361 {
362 CheckDlgButton(hwndDlg, IDC_USER_GENERAL_FORCE_CHANGE,
363 pUserData->dwPasswordExpired ? BST_CHECKED : BST_UNCHECKED);
364
365 CheckDlgButton(hwndDlg, IDC_USER_GENERAL_CANNOT_CHANGE,
366 (pUserData->dwFlags & UF_PASSWD_CANT_CHANGE) ? BST_CHECKED : BST_UNCHECKED);
367
368 CheckDlgButton(hwndDlg, IDC_USER_GENERAL_NEVER_EXPIRES,
369 (pUserData->dwFlags & UF_DONT_EXPIRE_PASSWD) ? BST_CHECKED : BST_UNCHECKED);
370
371 CheckDlgButton(hwndDlg, IDC_USER_GENERAL_DISABLED,
372 (pUserData->dwFlags & UF_ACCOUNTDISABLE) ? BST_CHECKED : BST_UNCHECKED);
373
374 CheckDlgButton(hwndDlg, IDC_USER_GENERAL_LOCKED,
375 (pUserData->dwFlags & UF_LOCKOUT) ? BST_CHECKED : BST_UNCHECKED);
376 }
377 }
378
379
380 static VOID
381 GetUserGeneralData(HWND hwndDlg,
382 PGENERAL_USER_DATA pUserData)
383 {
384 PUSER_INFO_3 pUserInfo = NULL;
385
386 SetDlgItemText(hwndDlg, IDC_USER_GENERAL_NAME, pUserData->szUserName);
387
388 NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&pUserInfo);
389
390 SetDlgItemText(hwndDlg, IDC_USER_GENERAL_FULL_NAME, pUserInfo->usri3_full_name);
391 SetDlgItemText(hwndDlg, IDC_USER_GENERAL_DESCRIPTION, pUserInfo->usri3_comment);
392
393 pUserData->dwFlags = pUserInfo->usri3_flags;
394 pUserData->dwPasswordExpired = pUserInfo->usri3_password_expired;
395
396 NetApiBufferFree(pUserInfo);
397
398 UpdateUserOptions(hwndDlg, pUserData, TRUE);
399 }
400
401
402 static BOOL
403 SetUserGeneralData(HWND hwndDlg,
404 PGENERAL_USER_DATA pUserData)
405 {
406 PUSER_INFO_3 pUserInfo = NULL;
407 LPTSTR pszFullName = NULL;
408 LPTSTR pszComment = NULL;
409 NET_API_STATUS status;
410 #if 0
411 DWORD dwIndex;
412 #endif
413 INT nLength;
414
415 NetUserGetInfo(NULL, pUserData->szUserName, 3, (LPBYTE*)&pUserInfo);
416
417 pUserInfo->usri3_flags =
418 (pUserData->dwFlags & VALID_GENERAL_FLAGS) |
419 (pUserInfo->usri3_flags & ~VALID_GENERAL_FLAGS);
420
421 pUserInfo->usri3_password_expired = pUserData->dwPasswordExpired;
422
423 nLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_USER_GENERAL_FULL_NAME));
424 if (nLength == 0)
425 {
426 pUserInfo->usri3_full_name = NULL;
427 }
428 else
429 {
430 pszFullName = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
431 GetDlgItemText(hwndDlg, IDC_USER_GENERAL_FULL_NAME, pszFullName, nLength + 1);
432 pUserInfo->usri3_full_name = pszFullName;
433 }
434
435 nLength = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_USER_GENERAL_DESCRIPTION));
436 if (nLength == 0)
437 {
438 pUserInfo->usri3_full_name = NULL;
439 }
440 else
441 {
442 pszComment = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
443 GetDlgItemText(hwndDlg, IDC_USER_GENERAL_DESCRIPTION, pszComment, nLength + 1);
444 pUserInfo->usri3_comment = pszComment;
445 }
446
447 #if 0
448 status = NetUserSetInfo(NULL, pUserData->szUserName, 3, (LPBYTE)pUserInfo, &dwIndex);
449 if (status != NERR_Success)
450 {
451 DebugPrintf(_T("Status: %lu Index: %lu"), status, dwIndex);
452 }
453 #else
454 status = NERR_Success;
455 #endif
456
457 if (pszFullName)
458 HeapFree(GetProcessHeap(), 0, pszFullName);
459
460 if (pszComment)
461 HeapFree(GetProcessHeap(), 0, pszComment);
462
463 NetApiBufferFree(pUserInfo);
464
465 return (status == NERR_Success);
466 }
467
468
469 INT_PTR CALLBACK
470 UserGeneralPageProc(HWND hwndDlg,
471 UINT uMsg,
472 WPARAM wParam,
473 LPARAM lParam)
474 {
475 PGENERAL_USER_DATA pUserData;
476
477 UNREFERENCED_PARAMETER(lParam);
478 UNREFERENCED_PARAMETER(wParam);
479 UNREFERENCED_PARAMETER(hwndDlg);
480
481 pUserData= (PGENERAL_USER_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
482
483 switch (uMsg)
484 {
485 case WM_INITDIALOG:
486 pUserData = (PGENERAL_USER_DATA)HeapAlloc(GetProcessHeap(),
487 HEAP_ZERO_MEMORY,
488 sizeof(GENERAL_USER_DATA) +
489 lstrlen((LPTSTR)((PROPSHEETPAGE *)lParam)->lParam) * sizeof(TCHAR));
490 lstrcpy(pUserData->szUserName, (LPTSTR)((PROPSHEETPAGE *)lParam)->lParam);
491
492 SetWindowLongPtr(hwndDlg, DWLP_USER, (INT_PTR)pUserData);
493
494 GetUserGeneralData(hwndDlg,
495 pUserData);
496 break;
497
498 case WM_COMMAND:
499 switch (LOWORD(wParam))
500 {
501 case IDC_USER_GENERAL_FULL_NAME:
502 case IDC_USER_GENERAL_DESCRIPTION:
503 if (HIWORD(wParam) == EN_CHANGE)
504 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
505 break;
506
507 case IDC_USER_GENERAL_FORCE_CHANGE:
508 pUserData->dwPasswordExpired = !pUserData->dwPasswordExpired;
509 UpdateUserOptions(hwndDlg, pUserData, FALSE);
510 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
511 break;
512
513 case IDC_USER_GENERAL_CANNOT_CHANGE:
514 pUserData->dwFlags ^= UF_PASSWD_CANT_CHANGE;
515 UpdateUserOptions(hwndDlg, pUserData, FALSE);
516 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
517 break;
518
519 case IDC_USER_GENERAL_NEVER_EXPIRES:
520 pUserData->dwFlags ^= UF_DONT_EXPIRE_PASSWD;
521 UpdateUserOptions(hwndDlg, pUserData, FALSE);
522 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
523 break;
524
525 case IDC_USER_GENERAL_DISABLED:
526 pUserData->dwFlags ^= UF_ACCOUNTDISABLE;
527 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
528 break;
529
530 case IDC_USER_GENERAL_LOCKED:
531 pUserData->dwFlags ^= UF_LOCKOUT;
532 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
533 break;
534 }
535 break;
536
537 case WM_NOTIFY:
538 if (((LPPSHNOTIFY)lParam)->hdr.code == PSN_APPLY)
539 {
540 SetUserGeneralData(hwndDlg, pUserData);
541 return TRUE;
542 }
543 break;
544
545 case WM_DESTROY:
546 HeapFree(GetProcessHeap(), 0, pUserData);
547 break;
548 }
549
550 return FALSE;
551 }
552
553
554 static VOID
555 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, LPTSTR pszUser)
556 {
557 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
558 psp->dwSize = sizeof(PROPSHEETPAGE);
559 psp->dwFlags = PSP_DEFAULT;
560 psp->hInstance = hApplet;
561 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
562 psp->pfnDlgProc = DlgProc;
563 psp->lParam = (LPARAM)pszUser;
564 }
565
566
567 BOOL
568 UserProperties(HWND hwndDlg)
569 {
570 PROPSHEETPAGE psp[3];
571 PROPSHEETHEADER psh;
572 TCHAR szUserName[UNLEN];
573 INT nItem;
574 HWND hwndLV;
575
576 hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);
577 nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);
578 if (nItem == -1)
579 return FALSE;
580
581 /* Get the new user name */
582 ListView_GetItemText(hwndLV,
583 nItem, 0,
584 szUserName,
585 UNLEN);
586
587 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
588 psh.dwSize = sizeof(PROPSHEETHEADER);
589 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE;
590 psh.hwndParent = hwndDlg;
591 psh.hInstance = hApplet;
592 psh.hIcon = NULL;
593 psh.pszCaption = szUserName;
594 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
595 psh.nStartPage = 0;
596 psh.ppsp = psp;
597
598 InitPropSheetPage(&psp[0], IDD_USER_GENERAL, (DLGPROC)UserGeneralPageProc, szUserName);
599 InitPropSheetPage(&psp[1], IDD_USER_MEMBERSHIP, (DLGPROC)UserMembershipPageProc, szUserName);
600 InitPropSheetPage(&psp[2], IDD_USER_PROFILE, (DLGPROC)UserProfilePageProc, szUserName);
601
602 return (PropertySheet(&psh) == IDOK);
603 }