2 * PROJECT: ReactOS Services
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/mscutils/servman/propsheet_general.c
5 * PURPOSE: Property dialog box message handler
6 * COPYRIGHT: Copyright 2006-2009 Ged Murphy <gedmurphy@reactos.org>
15 SetButtonStates(PSERVICEPROPSHEET dlgInfo
,
19 LPQUERY_SERVICE_CONFIG lpServiceConfig
;
23 Flags
= dlgInfo
->pService
->ServiceStatusProcess
.dwControlsAccepted
;
24 State
= dlgInfo
->pService
->ServiceStatusProcess
.dwCurrentState
;
26 for (i
= IDC_START
; i
<= IDC_RESUME
; i
++)
28 hButton
= GetDlgItem(hwndDlg
, i
);
29 EnableWindow (hButton
, FALSE
);
32 lpServiceConfig
= GetServiceConfig(dlgInfo
->pService
->lpServiceName
);
33 if (State
== SERVICE_STOPPED
&&
34 lpServiceConfig
&& lpServiceConfig
->dwStartType
!= SERVICE_DISABLED
)
36 hButton
= GetDlgItem(hwndDlg
, IDC_START
);
37 EnableWindow (hButton
, TRUE
);
38 HeapFree(GetProcessHeap(), 0, lpServiceConfig
);
40 else if ( (Flags
& SERVICE_ACCEPT_STOP
) && (State
== SERVICE_RUNNING
) )
42 hButton
= GetDlgItem(hwndDlg
, IDC_STOP
);
43 EnableWindow (hButton
, TRUE
);
45 else if ( (Flags
& SERVICE_ACCEPT_PAUSE_CONTINUE
) && (State
== SERVICE_RUNNING
) )
47 hButton
= GetDlgItem(hwndDlg
, IDC_PAUSE
);
48 EnableWindow (hButton
, TRUE
);
51 /* set the main toolbar */
52 SetMenuAndButtonStates(dlgInfo
->Info
);
57 SetServiceStatusText(PSERVICEPROPSHEET dlgInfo
,
63 if (dlgInfo
->pService
->ServiceStatusProcess
.dwCurrentState
== SERVICE_RUNNING
)
65 id
= IDS_SERVICES_STARTED
;
69 id
= IDS_SERVICES_STOPPED
;
72 if (AllocAndLoadString(&lpStatus
,
76 SendDlgItemMessage(hwndDlg
,
86 * Fills the 'startup type' combo box with possible
87 * values and sets it to value of the selected item
90 SetStartupType(LPTSTR lpServiceName
,
94 LPQUERY_SERVICE_CONFIG pServiceConfig
;
99 hList
= GetDlgItem(hwndDlg
, IDC_START_TYPE
);
101 for (i
= IDS_SERVICES_AUTO
; i
<= IDS_SERVICES_DIS
; i
++)
103 if (AllocAndLoadString(&lpBuf
,
115 pServiceConfig
= GetServiceConfig(lpServiceName
);
119 switch (pServiceConfig
->dwStartType
)
121 case SERVICE_AUTO_START
: StartUp
= 0; break;
122 case SERVICE_DEMAND_START
: StartUp
= 1; break;
123 case SERVICE_DISABLED
: StartUp
= 2; break;
131 HeapFree(ProcessHeap
,
139 * Populates the General Properties dialog with
140 * the relevant service information
143 InitGeneralPage(PSERVICEPROPSHEET dlgInfo
,
146 LPQUERY_SERVICE_CONFIG pServiceConfig
;
147 LPTSTR lpDescription
;
149 /* set the service name */
150 SendDlgItemMessage(hwndDlg
,
154 (LPARAM
)dlgInfo
->pService
->lpServiceName
);
156 /* set the display name */
157 SendDlgItemMessage(hwndDlg
,
161 (LPARAM
)dlgInfo
->pService
->lpDisplayName
);
163 /* set the description */
164 if ((lpDescription
= GetServiceDescription(dlgInfo
->pService
->lpServiceName
)))
166 SendDlgItemMessage(hwndDlg
,
170 (LPARAM
)lpDescription
);
172 HeapFree(ProcessHeap
,
177 pServiceConfig
= GetServiceConfig(dlgInfo
->pService
->lpServiceName
);
180 SendDlgItemMessage(hwndDlg
,
184 (LPARAM
)pServiceConfig
->lpBinaryPathName
);
185 HeapFree(ProcessHeap
,
191 /* set startup type */
192 SetStartupType(dlgInfo
->pService
->lpServiceName
, hwndDlg
);
194 SetServiceStatusText(dlgInfo
,
197 if (dlgInfo
->Info
->bIsUserAnAdmin
)
199 HWND hEdit
= GetDlgItem(hwndDlg
,
208 SaveDlgInfo(PSERVICEPROPSHEET dlgInfo
,
211 LPQUERY_SERVICE_CONFIG pServiceConfig
= NULL
;
215 pServiceConfig
= HeapAlloc(ProcessHeap
,
217 sizeof(*pServiceConfig
));
220 pServiceConfig
->dwServiceType
= SERVICE_NO_CHANGE
;
221 pServiceConfig
->dwErrorControl
= SERVICE_NO_CHANGE
;
223 hList
= GetDlgItem(hwndDlg
, IDC_START_TYPE
);
224 StartUp
= SendMessage(hList
,
230 case 0: pServiceConfig
->dwStartType
= SERVICE_AUTO_START
; break;
231 case 1: pServiceConfig
->dwStartType
= SERVICE_DEMAND_START
; break;
232 case 2: pServiceConfig
->dwStartType
= SERVICE_DISABLED
; break;
235 if (SetServiceConfig(pServiceConfig
,
236 dlgInfo
->pService
->lpServiceName
,
239 ChangeListViewText(dlgInfo
->Info
,
244 HeapFree(ProcessHeap
,
252 * General Property dialog callback.
253 * Controls messages to the General dialog
256 GeneralPageProc(HWND hwndDlg
,
261 PSERVICEPROPSHEET dlgInfo
;
263 /* Get the window context */
264 dlgInfo
= (PSERVICEPROPSHEET
)GetWindowLongPtr(hwndDlg
,
266 if (dlgInfo
== NULL
&& uMsg
!= WM_INITDIALOG
)
275 dlgInfo
= (PSERVICEPROPSHEET
)(((LPPROPSHEETPAGE
)lParam
)->lParam
);
278 SetWindowLongPtr(hwndDlg
,
281 InitGeneralPage(dlgInfo
, hwndDlg
);
282 SetButtonStates(dlgInfo
, hwndDlg
);
288 switch(LOWORD(wParam
))
291 if (HIWORD(wParam
) == CBN_SELCHANGE
)
292 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
296 if (DoStart(dlgInfo
->Info
))
298 UpdateServiceStatus(dlgInfo
->pService
);
299 ChangeListViewText(dlgInfo
->Info
, dlgInfo
->pService
, LVSTATUS
);
300 SetButtonStates(dlgInfo
, hwndDlg
);
301 SetServiceStatusText(dlgInfo
, hwndDlg
);
306 if (DoStop(dlgInfo
->Info
))
308 UpdateServiceStatus(dlgInfo
->pService
);
309 ChangeListViewText(dlgInfo
->Info
, dlgInfo
->pService
, LVSTATUS
);
310 SetButtonStates(dlgInfo
, hwndDlg
);
311 SetServiceStatusText(dlgInfo
, hwndDlg
);
316 if (DoPause(dlgInfo
->Info
))
318 UpdateServiceStatus(dlgInfo
->pService
);
319 ChangeListViewText(dlgInfo
->Info
, dlgInfo
->pService
, LVSTATUS
);
320 SetButtonStates(dlgInfo
, hwndDlg
);
321 SetServiceStatusText(dlgInfo
, hwndDlg
);
326 if (DoResume(dlgInfo
->Info
))
328 UpdateServiceStatus(dlgInfo
->pService
);
329 ChangeListViewText(dlgInfo
->Info
, dlgInfo
->pService
, LVSTATUS
);
330 SetButtonStates(dlgInfo
, hwndDlg
);
331 SetServiceStatusText(dlgInfo
, hwndDlg
);
337 HWND hName
, hDesc
, hExePath
;
339 hName
= GetDlgItem(hwndDlg
, IDC_DISP_NAME
);
340 hDesc
= GetDlgItem(hwndDlg
, IDC_DESCRIPTION
);
341 hExePath
= GetDlgItem(hwndDlg
, IDC_EXEPATH
);
343 SendMessage(hName
, EM_SETREADONLY
, FALSE
, 0);
344 SendMessage(hDesc
, EM_SETREADONLY
, FALSE
, 0);
345 SendMessage(hExePath
, EM_SETREADONLY
, FALSE
, 0);
349 case IDC_START_PARAM
:
350 PropSheet_Changed(GetParent(hwndDlg
), hwndDlg
);
357 LPNMHDR lpnm
= (LPNMHDR
)lParam
;
362 SaveDlgInfo(dlgInfo
, hwndDlg
);
363 SetButtonStates(dlgInfo
, hwndDlg
);