From d8f1cef2f6ec466a750ec3d2f3266382c48fc002 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Thu, 11 Oct 2007 11:09:39 +0000 Subject: [PATCH] improve the button states in relation to the service svn path=/trunk/; revision=29500 --- .../applications/mscutils/servman/mainwnd.c | 48 ++++++++++--------- .../applications/mscutils/servman/precomp.h | 1 + .../applications/mscutils/servman/propsheet.c | 35 +++++++------- 3 files changed, 44 insertions(+), 40 deletions(-) diff --git a/reactos/base/applications/mscutils/servman/mainwnd.c b/reactos/base/applications/mscutils/servman/mainwnd.c index 5e250bc45bd..1afef868a9f 100644 --- a/reactos/base/applications/mscutils/servman/mainwnd.c +++ b/reactos/base/applications/mscutils/servman/mainwnd.c @@ -151,7 +151,6 @@ UpdateServiceCount(PMAIN_WND_INFO Info) VOID SetMenuAndButtonStates(PMAIN_WND_INFO Info) { - LPQUERY_SERVICE_CONFIG lpServiceConfig; HMENU hMainMenu; UINT i; @@ -169,6 +168,9 @@ VOID SetMenuAndButtonStates(PMAIN_WND_INFO Info) if (Info->SelectedItem != NO_ITEM_SELECTED) { + LPQUERY_SERVICE_CONFIG lpServiceConfig = NULL; + DWORD Flags, State; + /* allow user to delete service */ if (Info->bIsUserAnAdmin) { @@ -178,14 +180,13 @@ VOID SetMenuAndButtonStates(PMAIN_WND_INFO Info) EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_DELETE, MF_ENABLED); } + Flags = Info->pCurrentService->ServiceStatusProcess.dwControlsAccepted; + State = Info->pCurrentService->ServiceStatusProcess.dwCurrentState; + lpServiceConfig = GetServiceConfig(Info->pCurrentService->lpServiceName); + if (lpServiceConfig && lpServiceConfig->dwStartType != SERVICE_DISABLED) { - DWORD Flags, State; - - Flags = Info->pCurrentService->ServiceStatusProcess.dwControlsAccepted; - State = Info->pCurrentService->ServiceStatusProcess.dwCurrentState; - if (State == SERVICE_STOPPED) { EnableMenuItem(hMainMenu, ID_START, MF_ENABLED); @@ -193,23 +194,7 @@ VOID SetMenuAndButtonStates(PMAIN_WND_INFO Info) SendMessage(Info->hTool, TB_SETSTATE, ID_START, (LPARAM)MAKELONG(TBSTATE_ENABLED, 0)); } - - if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) ) - { - EnableMenuItem(hMainMenu, ID_STOP, MF_ENABLED); - EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_STOP, MF_ENABLED); - SendMessage(Info->hTool, TB_SETSTATE, ID_STOP, - (LPARAM)MAKELONG(TBSTATE_ENABLED, 0)); - } - - if ( (Flags & SERVICE_ACCEPT_PAUSE_CONTINUE) && (State == SERVICE_RUNNING) ) - { - EnableMenuItem(hMainMenu, ID_PAUSE, MF_ENABLED); - EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_PAUSE, MF_ENABLED); - SendMessage(Info->hTool, TB_SETSTATE, ID_PAUSE, - (LPARAM)MAKELONG(TBSTATE_ENABLED, 0)); - } - + if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) ) { EnableMenuItem(hMainMenu, ID_RESTART, MF_ENABLED); @@ -220,6 +205,22 @@ VOID SetMenuAndButtonStates(PMAIN_WND_INFO Info) HeapFree(GetProcessHeap(), 0, lpServiceConfig); } + + if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) ) + { + EnableMenuItem(hMainMenu, ID_STOP, MF_ENABLED); + EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_STOP, MF_ENABLED); + SendMessage(Info->hTool, TB_SETSTATE, ID_STOP, + (LPARAM)MAKELONG(TBSTATE_ENABLED, 0)); + } + + if ( (Flags & SERVICE_ACCEPT_PAUSE_CONTINUE) && (State == SERVICE_RUNNING) ) + { + EnableMenuItem(hMainMenu, ID_PAUSE, MF_ENABLED); + EnableMenuItem(GetSubMenu(Info->hShortcutMenu, 0), ID_PAUSE, MF_ENABLED); + SendMessage(Info->hTool, TB_SETSTATE, ID_PAUSE, + (LPARAM)MAKELONG(TBSTATE_ENABLED, 0)); + } } else { @@ -396,6 +397,7 @@ MainWndCommand(PMAIN_WND_INFO Info, Info->bDlgOpen = TRUE; OpenPropSheet(Info); Info->bDlgOpen = FALSE; + SetMenuAndButtonStates(Info); } } break; diff --git a/reactos/base/applications/mscutils/servman/precomp.h b/reactos/base/applications/mscutils/servman/precomp.h index eaf6eb1f5cf..b6fd9835aa4 100644 --- a/reactos/base/applications/mscutils/servman/precomp.h +++ b/reactos/base/applications/mscutils/servman/precomp.h @@ -60,6 +60,7 @@ typedef struct _MENU_HINT UINT HintId; } MENU_HINT, *PMENU_HINT; +VOID SetMenuAndButtonStates(PMAIN_WND_INFO Info); VOID UpdateServiceCount(PMAIN_WND_INFO Info); VOID ChangeListViewText(PMAIN_WND_INFO Info, ENUM_SERVICE_STATUS_PROCESS* pService, UINT Column); BOOL InitMainWindowImpl(VOID); diff --git a/reactos/base/applications/mscutils/servman/propsheet.c b/reactos/base/applications/mscutils/servman/propsheet.c index aaddb884cd4..bd52dd48ae0 100644 --- a/reactos/base/applications/mscutils/servman/propsheet.c +++ b/reactos/base/applications/mscutils/servman/propsheet.c @@ -35,26 +35,26 @@ SetButtonStates(PSERVICEPROPSHEET dlgInfo, } lpServiceConfig = GetServiceConfig(dlgInfo->pService->lpServiceName); - if (lpServiceConfig && lpServiceConfig->dwStartType != SERVICE_DISABLED) + if (State == SERVICE_STOPPED && + lpServiceConfig && lpServiceConfig->dwStartType != SERVICE_DISABLED) { - if (State == SERVICE_STOPPED) - { - hButton = GetDlgItem(hwndDlg, IDC_START); - EnableWindow (hButton, TRUE); - } - else if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) ) - { - hButton = GetDlgItem(hwndDlg, IDC_STOP); - EnableWindow (hButton, TRUE); - } - else if ( (Flags & SERVICE_ACCEPT_PAUSE_CONTINUE) && (State == SERVICE_RUNNING) ) - { - hButton = GetDlgItem(hwndDlg, IDC_PAUSE); - EnableWindow (hButton, TRUE); - } - + hButton = GetDlgItem(hwndDlg, IDC_START); + EnableWindow (hButton, TRUE); HeapFree(GetProcessHeap(), 0, lpServiceConfig); } + else if ( (Flags & SERVICE_ACCEPT_STOP) && (State == SERVICE_RUNNING) ) + { + hButton = GetDlgItem(hwndDlg, IDC_STOP); + EnableWindow (hButton, TRUE); + } + else if ( (Flags & SERVICE_ACCEPT_PAUSE_CONTINUE) && (State == SERVICE_RUNNING) ) + { + hButton = GetDlgItem(hwndDlg, IDC_PAUSE); + EnableWindow (hButton, TRUE); + } + + /* set the main toolbar */ + SetMenuAndButtonStates(dlgInfo->Info); } @@ -365,6 +365,7 @@ GeneralPageProc(HWND hwndDlg, { case PSN_APPLY: SaveDlgInfo(dlgInfo, hwndDlg); + SetButtonStates(dlgInfo, hwndDlg); break; } }