Author: gedmurphy
Date: Fri Aug 31 15:03:29 2007
New Revision: 28695
URL:
http://svn.reactos.org/svn/reactos?rev=28695&view=rev
Log:
fix controlling a service from the properties dialog and update the listview accordingly
Modified:
trunk/reactos/base/applications/mscutils/servman/misc.c
trunk/reactos/base/applications/mscutils/servman/propsheet.c
trunk/reactos/base/applications/mscutils/servman/resource.h
Modified: trunk/reactos/base/applications/mscutils/servman/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/misc.c (original)
+++ trunk/reactos/base/applications/mscutils/servman/misc.c Fri Aug 31 15:03:29 2007
@@ -3,7 +3,8 @@
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/system/servman/misc.c
* PURPOSE: miscallanous functions
- * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy(a)gmail.com>
+ * COPYRIGHT: Copyright 2005 Thomas Weidenmueller <w3seek(a)reactos.org>
+ * Copyright 2006 Ged Murphy <gedmurphy(a)gmail.com>
*
*/
Modified: trunk/reactos/base/applications/mscutils/servman/propsheet.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/propsheet.c (original)
+++ trunk/reactos/base/applications/mscutils/servman/propsheet.c Fri Aug 31 15:03:29 2007
@@ -22,10 +22,17 @@
{
HWND hButton;
DWORD Flags, State;
+ UINT i;
Flags = dlgInfo->pService->ServiceStatusProcess.dwControlsAccepted;
State = dlgInfo->pService->ServiceStatusProcess.dwCurrentState;
+ for (i = IDC_START; i <= 10104; i++)
+ {
+ hButton = GetDlgItem(hwndDlg, i);
+ EnableWindow (hButton, FALSE);
+ }
+
if (State == SERVICE_STOPPED)
{
hButton = GetDlgItem(hwndDlg, IDC_START);
@@ -43,11 +50,37 @@
hButton = GetDlgItem(hwndDlg, IDC_PAUSE);
EnableWindow (hButton, TRUE);
}
-
- if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) )
- {
- hButton = GetDlgItem(hwndDlg, IDC_PAUSE);
- EnableWindow (hButton, TRUE);
+}
+
+
+static VOID
+SetServiceStatusText(PSERVICEPROPSHEET dlgInfo,
+ HWND hwndDlg)
+{
+ LPTSTR lpStatus;
+ UINT id;
+
+ if (dlgInfo->pService->ServiceStatusProcess.dwCurrentState == SERVICE_RUNNING)
+ {
+ id = IDS_SERVICES_STARTED;
+ }
+ else
+ {
+ id = IDS_SERVICES_STOPPED;
+ }
+
+ if (AllocAndLoadString(&lpStatus,
+ hInstance,
+ id))
+ {
+ SendDlgItemMessage(hwndDlg,
+ IDC_SERV_STATUS,
+ WM_SETTEXT,
+ 0,
+ (LPARAM)lpStatus);
+ HeapFree(ProcessHeap,
+ 0,
+ lpStatus);
}
}
@@ -159,37 +192,8 @@
/* set startup type */
SetStartupType(dlgInfo->pService->lpServiceName, hwndDlg);
- /* set service status */
- if (dlgInfo->pService->ServiceStatusProcess.dwCurrentState == SERVICE_RUNNING)
- {
- TCHAR szServiceStatus[32];
-
- LoadString(hInstance,
- IDS_SERVICES_STARTED,
- szServiceStatus,
- _tcslen(szServiceStatus) + 1);
-
- SendDlgItemMessage(hwndDlg,
- IDC_SERV_STATUS,
- WM_SETTEXT,
- 0,
- (LPARAM)szServiceStatus);
- }
- else
- {
- TCHAR szServiceStatus[32];
-
- LoadString(hInstance,
- IDS_SERVICES_STOPPED,
- szServiceStatus,
- _tcslen(szServiceStatus) + 1);
-
- SendDlgItemMessage(hwndDlg,
- IDC_SERV_STATUS,
- WM_SETTEXT,
- 0,
- (LPARAM)szServiceStatus);
- }
+ SetServiceStatusText(dlgInfo,
+ hwndDlg);
if (dlgInfo->Info->bIsUserAnAdmin)
{
@@ -292,22 +296,41 @@
case IDC_START:
if (DoStart(dlgInfo->Info))
{
- //UpdateServiceStatus(dlgInfo->pService);
- //ChangeListViewText(dlgInfo, LVSTATUS);
- //SetMenuAndButtonStates(Info);
+ UpdateServiceStatus(dlgInfo->pService);
+ ChangeListViewText(dlgInfo->Info, dlgInfo->pService,
LVSTATUS);
+ SetButtonStates(dlgInfo, hwndDlg);
+ SetServiceStatusText(dlgInfo, hwndDlg);
}
break;
case IDC_STOP:
- //SendMessage(Info->hMainWnd, WM_COMMAND, ID_STOP, 0);
+ if (DoStop(dlgInfo->Info))
+ {
+ UpdateServiceStatus(dlgInfo->pService);
+ ChangeListViewText(dlgInfo->Info, dlgInfo->pService,
LVSTATUS);
+ SetButtonStates(dlgInfo, hwndDlg);
+ SetServiceStatusText(dlgInfo, hwndDlg);
+ }
break;
case IDC_PAUSE:
- //SendMessage(Info->hMainWnd, WM_COMMAND, ID_PAUSE, 0);
+ if (DoPause(dlgInfo->Info))
+ {
+ UpdateServiceStatus(dlgInfo->pService);
+ ChangeListViewText(dlgInfo->Info, dlgInfo->pService,
LVSTATUS);
+ SetButtonStates(dlgInfo, hwndDlg);
+ SetServiceStatusText(dlgInfo, hwndDlg);
+ }
break;
case IDC_RESUME:
- //SendMessage(Info->hMainWnd, WM_COMMAND, ID_RESUME, 0);
+ if (DoResume(dlgInfo->Info))
+ {
+ UpdateServiceStatus(dlgInfo->pService);
+ ChangeListViewText(dlgInfo->Info, dlgInfo->pService,
LVSTATUS);
+ SetButtonStates(dlgInfo, hwndDlg);
+ SetServiceStatusText(dlgInfo, hwndDlg);
+ }
break;
case IDC_EDIT:
@@ -396,36 +419,6 @@
}
-static INT CALLBACK
-AddEditButton(HWND hwnd, UINT message, LPARAM lParam)
-{
- HWND hEditButton;
-
- switch (message)
- {
- case PSCB_PRECREATE:
- /*hEditButton = CreateWindowEx(0,
- WC_BUTTON,
- NULL,
- WS_CHILD | WS_VISIBLE,
- 20, 300, 30, 15,
- hwnd,
- NULL,
- hInstance,
- NULL);
- if (hEditButton == NULL)
- GetError(0);*/
-
- hEditButton = GetDlgItem(hwnd, PSBTN_OK);
- DestroyWindow(hEditButton);
- //SetWindowText(hEditButton, _T("test"));
-
- return TRUE;
- }
- return TRUE;
-}
-
-
static VOID
InitPropSheetPage(PROPSHEETPAGE *psp,
PSERVICEPROPSHEET dlgInfo,
@@ -459,7 +452,6 @@
psh.pszCaption = Info->pCurrentService->lpDisplayName;
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
psh.nStartPage = 0;
- psh.pfnCallback = AddEditButton;
psh.ppsp = psp;
Modified: trunk/reactos/base/applications/mscutils/servman/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/mscutils…
==============================================================================
--- trunk/reactos/base/applications/mscutils/servman/resource.h (original)
+++ trunk/reactos/base/applications/mscutils/servman/resource.h Fri Aug 31 15:03:29 2007
@@ -121,18 +121,18 @@
/* properties dialog */
#define IDD_DLG_GENERAL 10001
-#define IDC_SERV_NAME 10041
-#define IDC_DISP_NAME 10051
-#define IDC_DESCRIPTION 10061
-#define IDC_EXEPATH 10062
-#define IDC_START_TYPE 10101
-#define IDC_SERV_STATUS 10121
-#define IDC_START 10131
-#define IDC_STOP 10141
-#define IDC_PAUSE 10151
-#define IDC_RESUME 10161
-#define IDC_START_PARAM 10191
-#define IDC_EDIT 10192
+#define IDC_SERV_NAME 10002
+#define IDC_DISP_NAME 10003
+#define IDC_DESCRIPTION 10004
+#define IDC_EXEPATH 10005
+#define IDC_START_TYPE 10006
+#define IDC_SERV_STATUS 10007
+#define IDC_START_PARAM 10008
+#define IDC_EDIT 10009
+#define IDC_START 10101
+#define IDC_STOP 10102
+#define IDC_PAUSE 10103
+#define IDC_RESUME 10104
/* dependancies dialog */
#define IDD_DLG_DEPEND 20001