- Add icons for user, locked user and group.
authorEric Kohl <eric.kohl@reactos.org>
Sun, 2 Dec 2007 14:35:59 +0000 (14:35 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 2 Dec 2007 14:35:59 +0000 (14:35 +0000)
- Enable users to change their name and password (not fully working yet).
- Use the IDI_ prefix for icons.

svn path=/trunk/; revision=30958

reactos/dll/cpl/usrmgr/groups.c
reactos/dll/cpl/usrmgr/lang/en-US.rc
reactos/dll/cpl/usrmgr/resource.h
reactos/dll/cpl/usrmgr/resources/group.ico [new file with mode: 0644]
reactos/dll/cpl/usrmgr/resources/locked.ico [new file with mode: 0644]
reactos/dll/cpl/usrmgr/resources/user.ico [new file with mode: 0644]
reactos/dll/cpl/usrmgr/users.c
reactos/dll/cpl/usrmgr/usrmgr.c
reactos/dll/cpl/usrmgr/usrmgr.rbuild
reactos/dll/cpl/usrmgr/usrmgr.rc

index fbb3475..7778bbc 100644 (file)
@@ -29,8 +29,8 @@ SetGroupsListColumns(HWND hwndListView)
     GetClientRect(hwndListView, &rect);\r
 \r
     memset(&column, 0x00, sizeof(column));\r
-    column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;\r
-    column.fmt=LVCFMT_LEFT;\r
+    column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT;\r
+    column.fmt = LVCFMT_LEFT;\r
     column.cx = (INT)((rect.right - rect.left) * 0.40);\r
     column.iSubItem = 0;\r
     LoadString(hApplet, IDS_NAME, szStr, sizeof(szStr) / sizeof(szStr[0]));\r
index 248c07b..d278bcf 100644 (file)
@@ -12,7 +12,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
 CAPTION "Users"
 FONT 8, "MS Shell Dlg"
 BEGIN
-    CONTROL "", IDC_USERS_LIST, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
+    CONTROL "", IDC_USERS_LIST, "SysListView32", LVS_REPORT | LVS_EDITLABELS | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
             7, 7, 238, 85, WS_EX_CLIENTEDGE
 END
 
@@ -22,7 +22,7 @@ STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
 CAPTION "Groups"
 FONT 8, "MS Shell Dlg"
 BEGIN
-    CONTROL "", IDC_GROUPS_LIST, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
+    CONTROL "", IDC_GROUPS_LIST, "SysListView32", LVS_REPORT | LVS_EDITLABELS | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
             7, 7, 238, 85, WS_EX_CLIENTEDGE
 END
 
@@ -36,6 +36,31 @@ BEGIN
 END
 
 
+IDD_USER_GENERAL DIALOGEX DISCARDABLE  0, 0, 252, 223
+STYLE DS_SHELLFONT | WS_CHILD | WS_DISABLED | WS_CAPTION
+CAPTION "General"
+FONT 8, "MS Shell Dlg"
+BEGIN
+    LTEXT "", IDC_USER_NAME, 7, 7, 112, 8
+
+END
+
+
+
+IDD_CHANGE_PASSWORD DIALOGEX DISCARDABLE  0, 0, 267, 74
+STYLE DS_SHELLFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Change Password"
+FONT 8, "MS Shell Dlg"
+BEGIN
+    EDITTEXT        IDC_EDIT_PASSWORD1,107,7,153,14,ES_AUTOHSCROLL
+    RTEXT           "New Password:", -1,7,10,96,8
+    EDITTEXT        IDC_EDIT_PASSWORD2,107,25,153,14,ES_AUTOHSCROLL
+    RTEXT           "Repeat Password:", -1,7,28,96,8
+    DEFPUSHBUTTON   "OK",IDOK,156,53,50,14
+    PUSHBUTTON      "Abbrechen",IDCANCEL,210,53,50,14
+END
+
+
 /* Menus */
 
 IDM_POPUP_GROUP MENU DISCARDABLE
index 2777946..cd413e8 100644 (file)
 \r
 #define ICONSIZE            16\r
 \r
-/* ids */\r
 \r
-#define IDC_USRMGR_ICON                   40\r
-#define IDC_USRMGR_ICON2                  100 // Needed for theme compatability with Windows.\r
+/* Icons */\r
+#define IDI_USRMGR_ICON                 40\r
+#define IDI_USRMGR_ICON2                100 // Needed for theme compatibility with Windows.\r
+#define IDI_USER                        41\r
+#define IDI_LOCKED_USER                 42\r
+#define IDI_GROUP                       43\r
+\r
 \r
 #define IDD_USERS                       100\r
 #define IDD_GROUPS                      101\r
 #define IDC_STATIC                      -1\r
 \r
 \r
+/* Dialogs */\r
+\r
+#define IDD_USER_GENERAL            310\r
+#define IDC_USER_NAME               311\r
+#define IDC_USER_FULLNAME           312\r
+#define IDC_USER_DESCRIPTION        313\r
+#define IDC_USER_PW_CHANGE          314\r
+#define IDC_USER_PW_NOCHANGE        315\r
+#define IDC_USER_PW_EXPIRE          316\r
+#define IDC_USER_DEACTIVATE         317\r
+#define IDC_USER_LOCK               318\r
+\r
+\r
+#define IDD_CHANGE_PASSWORD         350\r
+#define IDC_EDIT_PASSWORD1          351\r
+#define IDC_EDIT_PASSWORD2          352\r
+\r
+\r
+/* Strings */\r
+\r
 #define IDS_CPLNAME                 2000\r
 #define IDS_CPLDESCRIPTION          2001\r
 \r
@@ -36,7 +60,9 @@
 #define IDS_FULLNAME                2101\r
 #define IDS_DESCRIPTION             2102\r
 \r
+\r
 /* Menus */\r
+\r
 #define IDM_POPUP_GROUP             120\r
 #define IDM_GROUP_ADD_MEMBER        121\r
 #define IDM_GROUP_NEW               122\r
diff --git a/reactos/dll/cpl/usrmgr/resources/group.ico b/reactos/dll/cpl/usrmgr/resources/group.ico
new file mode 100644 (file)
index 0000000..6a7c73a
Binary files /dev/null and b/reactos/dll/cpl/usrmgr/resources/group.ico differ
diff --git a/reactos/dll/cpl/usrmgr/resources/locked.ico b/reactos/dll/cpl/usrmgr/resources/locked.ico
new file mode 100644 (file)
index 0000000..9953f9d
Binary files /dev/null and b/reactos/dll/cpl/usrmgr/resources/locked.ico differ
diff --git a/reactos/dll/cpl/usrmgr/resources/user.ico b/reactos/dll/cpl/usrmgr/resources/user.ico
new file mode 100644 (file)
index 0000000..1868683
Binary files /dev/null and b/reactos/dll/cpl/usrmgr/resources/user.ico differ
index f0d60ad..b48711a 100644 (file)
@@ -20,6 +20,69 @@ typedef struct _USER_DATA
 } USER_DATA, *PUSER_DATA;\r
 \r
 \r
+\r
+static BOOL\r
+SetPassword(HWND hwndDlg)\r
+{\r
+    TCHAR szPassword1[256];\r
+    TCHAR szPassword2[256];\r
+    UINT uLen1;\r
+    UINT uLen2;\r
+\r
+    uLen1 = GetDlgItemText(hwndDlg, IDC_EDIT_PASSWORD1, szPassword1, 256);\r
+    uLen2 = GetDlgItemText(hwndDlg, IDC_EDIT_PASSWORD2, szPassword2, 256);\r
+\r
+    /* Check the passwords */\r
+    if (uLen1 != uLen2 || _tcscmp(szPassword1, szPassword2) != 0)\r
+    {\r
+        MessageBox(hwndDlg,\r
+                   TEXT("The passwords you entered are not the same!"),\r
+                   TEXT("ERROR"),\r
+                   MB_OK | MB_ICONERROR);\r
+        return FALSE;\r
+    }\r
+\r
+\r
+    return TRUE;\r
+}\r
+\r
+\r
+INT_PTR CALLBACK\r
+ChangePasswordDlgProc(HWND hwndDlg,\r
+                      UINT uMsg,\r
+                      WPARAM wParam,\r
+                      LPARAM lParam)\r
+{\r
+    UNREFERENCED_PARAMETER(wParam);\r
+\r
+    switch (uMsg)\r
+    {\r
+        case WM_INITDIALOG:\r
+            break;\r
+\r
+        case WM_COMMAND:\r
+            switch (LOWORD(wParam))\r
+            {\r
+                case IDOK:\r
+                    if (SetPassword(hwndDlg))\r
+                        EndDialog(hwndDlg, 0);\r
+                    break;\r
+\r
+                case IDCANCEL:\r
+                    EndDialog(hwndDlg, 0);\r
+                    break;\r
+            }\r
+            break;\r
+\r
+        default:\r
+            return FALSE;\r
+    }\r
+\r
+    return TRUE;\r
+}\r
+\r
+\r
+\r
 static VOID\r
 SetUsersListColumns(HWND hwndListView)\r
 {\r
@@ -120,7 +183,46 @@ OnInitDialog(HWND hwndDlg)
 }\r
 \r
 \r
-static VOID\r
+static BOOL\r
+OnEndLabelEdit(LPNMLVDISPINFO pnmv)\r
+{\r
+    TCHAR szOldUserName[UNLEN];\r
+    TCHAR szNewUserName[UNLEN];\r
+    USER_INFO_0 useri0;\r
+    NET_API_STATUS status;\r
+\r
+    if (pnmv->item.iItem == -1)\r
+        return FALSE;\r
+\r
+    ListView_GetItemText(pnmv->hdr.hwndFrom,\r
+                         pnmv->item.iItem, 0,\r
+                         szOldUserName,\r
+                         UNLEN);\r
+    lstrcpy(szNewUserName, pnmv->item.pszText);\r
+\r
+    if (lstrcmp(szOldUserName, szNewUserName) == 0)\r
+        return FALSE;\r
+\r
+    useri0.usri0_name = szNewUserName;\r
+\r
+    status = NetUserSetInfo(NULL, szOldUserName, 0, (LPBYTE)&useri0, NULL);\r
+    if (status != NERR_Success)\r
+    {\r
+        TCHAR szText[256];\r
+        wsprintf(szText, _T("Error: %u"), status);\r
+        MessageBox(NULL, szText, _T("NetUserSetInfo"), MB_ICONERROR | MB_OK);\r
+        return FALSE;\r
+    }\r
+\r
+    ListView_SetItemText(pnmv->hdr.hwndFrom,\r
+                         pnmv->item.iItem, 0,\r
+                         szNewUserName);\r
+\r
+    return TRUE;\r
+}\r
+\r
+\r
+static BOOL\r
 OnNotify(HWND hwndDlg, PUSER_DATA pUserData, NMHDR *phdr)\r
 {\r
     LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)phdr;\r
@@ -143,6 +245,9 @@ OnNotify(HWND hwndDlg, PUSER_DATA pUserData, NMHDR *phdr)
                 case NM_DBLCLK:\r
                     break;\r
 \r
+                case LVN_ENDLABELEDIT:\r
+                    return OnEndLabelEdit((LPNMLVDISPINFO)phdr);\r
+\r
                 case NM_RCLICK:\r
                     ClientToScreen(GetDlgItem(hwndDlg, IDC_USERS_LIST), &lpnmlv->ptAction);\r
                     TrackPopupMenu(GetSubMenu(pUserData->hPopupMenu, (lpnmlv->iItem == -1) ? 0 : 1),\r
@@ -151,6 +256,8 @@ OnNotify(HWND hwndDlg, PUSER_DATA pUserData, NMHDR *phdr)
             }\r
             break;\r
     }\r
+\r
+    return FALSE;\r
 }\r
 \r
 \r
@@ -180,6 +287,28 @@ UsersPageProc(HWND hwndDlg,
         case WM_COMMAND:\r
             switch (LOWORD(wParam))\r
             {\r
+                case IDM_USER_CHANGE_PASSWORD:\r
+                    DialogBoxParam(hApplet,\r
+                                   MAKEINTRESOURCE(IDD_CHANGE_PASSWORD),\r
+                                   hwndDlg,\r
+                                   ChangePasswordDlgProc,\r
+                                   (LPARAM)NULL);\r
+                    break;\r
+\r
+                case IDM_USER_RENAME:\r
+                    {\r
+                        INT nItem;\r
+                        HWND hwndLV;\r
+\r
+                        hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST);\r
+                        nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED);\r
+                        if (nItem != -1)\r
+                        {\r
+                            (void)ListView_EditLabel(hwndLV, nItem);\r
+                        }\r
+                    }\r
+                    break;\r
+\r
                 case IDM_USER_PROPERTIES:\r
                     MessageBeep(-1);\r
                     break;\r
@@ -187,8 +316,7 @@ UsersPageProc(HWND hwndDlg,
             break;\r
 \r
         case WM_NOTIFY:\r
-            OnNotify(hwndDlg, pUserData, (NMHDR *)lParam);\r
-            break;\r
+            return OnNotify(hwndDlg, pUserData, (NMHDR *)lParam);\r
 \r
         case WM_DESTROY:\r
             DestroyMenu(pUserData->hPopupMenu);\r
index 992441e..c622bea 100644 (file)
@@ -20,7 +20,7 @@ HINSTANCE hApplet = 0;
 APPLET Applets[NUM_APPLETS] =\r
 {\r
     {\r
-        IDC_USRMGR_ICON,\r
+        IDI_USRMGR_ICON,\r
         IDS_CPLNAME,\r
         IDS_CPLDESCRIPTION,\r
         UsrmgrApplet\r
@@ -60,7 +60,7 @@ UsrmgrApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
     psh.dwFlags =  PSH_PROPSHEETPAGE;\r
     psh.hwndParent = NULL;\r
     psh.hInstance = hApplet;\r
-    psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_USRMGR_ICON));\r
+    psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_USRMGR_ICON));\r
     psh.pszCaption = Caption;\r
     psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);\r
     psh.nStartPage = 0;\r
index 764a542..42b5e32 100644 (file)
@@ -5,6 +5,7 @@
        <include base="usrmgr">.</include>\r
        <define name="_WIN32_IE">0x600</define>\r
        <define name="_WIN32_WINNT">0x501</define>\r
+       <define name="WINVER">0x609</define>\r
        <library>kernel32</library>\r
        <library>user32</library>\r
        <library>gdi32</library>\r
index f547cae..9455253 100644 (file)
@@ -11,7 +11,11 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 
 123 24 DISCARDABLE "manifest.xml"
 
-IDC_USRMGR_ICON ICON "resources/applet.ico"
-IDC_USRMGR_ICON2 ICON "resources/applet.ico"
+IDI_USRMGR_ICON ICON "resources/applet.ico"
+IDI_USRMGR_ICON2 ICON "resources/applet.ico"
+
+IDI_USER ICON "resources/user.ico"
+IDI_LOCKED_USER ICON "resources/locked.ico"
+IDI_GROUP ICON "resources/group.ico"
 
 #include "rsrc.rc"