improve the button states in relation to the service

svn path=/trunk/; revision=29500
This commit is contained in:
Ged Murphy 2007-10-11 11:09:39 +00:00
parent 12be971541
commit d8f1cef2f6
3 changed files with 44 additions and 40 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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;
}
}