ReactOS 0.4.15-dev-8109-gd7be748
usrmgr.c
Go to the documentation of this file.
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 * Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
9 */
10
11#include "usrmgr.h"
12
13#define NUM_APPLETS 1
14
16
18
20{
21 INT nLength = GetWindowTextLength(GetDlgItem(hwndDlg, nDlgItem));
22 LPTSTR psz = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
23 if (psz)
24 GetDlgItemText(hwndDlg, nDlgItem, psz, nLength + 1);
25 return psz;
26}
27
28LPTSTR GetComboBoxLBTextAlloc(HWND hwndDlg, INT nDlgItem, INT nIndex)
29{
30 INT nLength = (INT)SendDlgItemMessage(hwndDlg, nDlgItem, CB_GETLBTEXTLEN, nIndex, 0);
31 LPTSTR psz = HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(TCHAR));
32 if (psz)
33 SendDlgItemMessage(hwndDlg, nDlgItem, CB_GETLBTEXT, nIndex, (LPARAM)psz);
34 return psz;
35}
36
37/* Applets */
39{
40 {
45 }
46};
47
48static VOID
50{
51 ZeroMemory(psp, sizeof(PROPSHEETPAGE));
52 psp->dwSize = sizeof(PROPSHEETPAGE);
53 psp->dwFlags = PSP_DEFAULT;
54 psp->hInstance = hApplet;
55 psp->pszTemplate = MAKEINTRESOURCE(idDlg);
56 psp->pfnDlgProc = DlgProc;
57}
58
59static int CALLBACK
61{
62 // NOTE: This callback is needed to set large icon correctly.
64 switch (uMsg)
65 {
67 {
69 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
70 break;
71 }
72 }
73 return 0;
74}
75
76/* Display Applet */
77static LONG APIENTRY
79{
80 PROPSHEETPAGE psp[2];
82
86
87 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
88 psh.dwSize = sizeof(PROPSHEETHEADER);
90 psh.hwndParent = hwnd;
91 psh.hInstance = hApplet;
92 psh.pszIcon = MAKEINTRESOURCEW(IDI_USRMGR_ICON);
93 psh.pszCaption = MAKEINTRESOURCEW(IDS_CPLNAME);
94 psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
95 psh.nStartPage = 0;
96 psh.ppsp = psp;
97 psh.pfnCallback = PropSheetProc;
98
101 /* InitPropSheetPage(&psp[2], IDD_EXTRA, ExtraPageProc); */
102
103 return (LONG)(PropertySheet(&psh) != -1);
104}
105
106
107/* Control Panel Callback */
109CPlApplet(HWND hwndCPl, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
110{
111 UINT i = (UINT)lParam1;
112
113 switch (uMsg)
114 {
115 case CPL_INIT:
116 return TRUE;
117
118 case CPL_GETCOUNT:
119 return NUM_APPLETS;
120
121 case CPL_INQUIRE:
122 if (i < NUM_APPLETS)
123 {
124 CPLINFO *CPlInfo = (CPLINFO*)lParam2;
125 CPlInfo->lData = 0;
126 CPlInfo->idIcon = Applets[i].idIcon;
127 CPlInfo->idName = Applets[i].idName;
128 CPlInfo->idInfo = Applets[i].idDescription;
129 }
130 else
131 {
132 return TRUE;
133 }
134 break;
135
136 case CPL_DBLCLK:
137 if (i < NUM_APPLETS)
138 Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
139 else
140 return TRUE;
141 break;
142 }
143
144 return FALSE;
145}
146
147
150{
152
153 switch (dwReason)
154 {
156 hApplet = hinstDLL;
157 break;
158 }
159
160 return TRUE;
161}
DWORD dwReason
Definition: misc.cpp:154
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define CPL_INQUIRE
Definition: cpl.h:14
#define CPL_DBLCLK
Definition: cpl.h:16
#define CPL_INIT
Definition: cpl.h:12
#define CPL_GETCOUNT
Definition: cpl.h:13
#define DLGPROC
Definition: maze.c:62
WORD idDlg
Definition: desk.c:121
DLGPROC DlgProc
Definition: desk.c:122
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDS_CPLNAME
Definition: resource.h:8
#define IDS_CPLDESCRIPTION
Definition: resource.h:9
#define IDD_USERS
Definition: resource.h:10
#define IDI_USRMGR_ICON
Definition: resource.h:4
#define IDD_GROUPS
Definition: resource.h:11
#define APIENTRY
Definition: api.h:79
#define GetProcessHeap()
Definition: compat.h:736
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define HeapAlloc
Definition: compat.h:733
#define CALLBACK
Definition: compat.h:35
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
INT_PTR CALLBACK GroupsPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: groups.c:425
static IN DWORD IN LPVOID lpvReserved
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
unsigned int UINT
Definition: ndis.h:50
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
long LONG
Definition: pedump.c:60
#define INT
Definition: polytest.cpp:20
#define PROPSHEETHEADER
Definition: prsht.h:392
#define PSH_USECALLBACK
Definition: prsht.h:48
#define PSP_DEFAULT
Definition: prsht.h:22
#define PropertySheet
Definition: prsht.h:400
#define PSH_PROPSHEETPAGE
Definition: prsht.h:43
#define PSH_USEICONID
Definition: prsht.h:42
#define PSCB_INITIALIZED
Definition: prsht.h:75
#define PROPSHEETPAGE
Definition: prsht.h:389
Definition: hotplug.h:34
int idDescription
Definition: hotplug.h:37
int idName
Definition: hotplug.h:36
int idIcon
Definition: hotplug.h:35
APPLET_PROC AppletProc
Definition: hotplug.h:38
Definition: cpl.h:24
LONG_PTR lData
Definition: cpl.h:28
int idName
Definition: cpl.h:26
int idInfo
Definition: cpl.h:27
int idIcon
Definition: cpl.h:25
#define ICON_BIG
Definition: tnclass.cpp:51
int32_t INT
Definition: typedefs.h:58
INT_PTR CALLBACK UsersPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: users.c:655
#define NUM_APPLETS
Definition: usrmgr.c:13
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: usrmgr.c:60
LPTSTR GetDlgItemTextAlloc(HWND hwndDlg, INT nDlgItem)
Definition: usrmgr.c:19
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
Definition: usrmgr.c:149
static VOID InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc)
Definition: usrmgr.c:49
APPLET Applets[NUM_APPLETS]
Definition: usrmgr.c:38
LPTSTR GetComboBoxLBTextAlloc(HWND hwndDlg, INT nDlgItem, INT nIndex)
Definition: usrmgr.c:28
static LONG APIENTRY UsrmgrApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
Definition: usrmgr.c:78
HINSTANCE hApplet
Definition: usrmgr.c:17
#define ZeroMemory
Definition: winbase.h:1712
_In_ DWORD nLength
Definition: wincon.h:473
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
#define WINAPI
Definition: msvc.h:6
#define CB_GETLBTEXTLEN
Definition: winuser.h:1953
#define CB_GETLBTEXT
Definition: winuser.h:1952
#define GetWindowTextLength
Definition: winuser.h:5799
#define GetDlgItemText
Definition: winuser.h:5785
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define SendDlgItemMessage
Definition: winuser.h:5842
#define MAKEINTRESOURCE
Definition: winuser.h:591
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2106
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192