Skip to content

Commit c28db43

Browse files
committed
Custom update interval option
1 parent d5e53a8 commit c28db43

File tree

4 files changed

+110
-1
lines changed

4 files changed

+110
-1
lines changed

main.cpp

+79
Original file line numberDiff line numberDiff line change
@@ -1914,6 +1914,69 @@ void ExecuteShutdownMenuOption(int iID)
19141914
}
19151915

19161916

1917+
/*++ CustomIntervalDlgProc
1918+
1919+
Routine Description:
1920+
1921+
Dialog procedure for Set Custom Interval dialog
1922+
1923+
Revision History:
1924+
1925+
Nov-02-24 aubymori Created
1926+
1927+
--*/
1928+
INT_PTR CALLBACK CustomIntervalDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
1929+
{
1930+
switch (uMsg)
1931+
{
1932+
case WM_INITDIALOG:
1933+
SendDlgItemMessageW(hwndDlg,
1934+
IDC_CUSTOM_INTERVAL_SPINNER,
1935+
UDM_SETRANGE32,
1936+
0,
1937+
MAXINT32);
1938+
SendDlgItemMessageW(hwndDlg,
1939+
IDC_CUSTOM_INTERVAL_SPINNER,
1940+
UDM_SETPOS32,
1941+
0,
1942+
g_Options.m_dwTimerInterval);
1943+
SetDlgItemInt(hwndDlg,
1944+
IDC_CUSTOM_INTERVAL_INPUT,
1945+
g_Options.m_dwTimerInterval,
1946+
FALSE);
1947+
return TRUE;
1948+
case WM_CLOSE:
1949+
EndDialog(hwndDlg, IDCANCEL);
1950+
return TRUE;
1951+
case WM_COMMAND:
1952+
switch (wParam)
1953+
{
1954+
case IDOK:
1955+
{
1956+
DWORD dwNewInterval = GetDlgItemInt(hwndDlg,
1957+
IDC_CUSTOM_INTERVAL_INPUT,
1958+
NULL,
1959+
FALSE);
1960+
1961+
// don't need to update if same time
1962+
if (dwNewInterval == g_Options.m_dwTimerInterval)
1963+
EndDialog(hwndDlg, IDCANCEL);
1964+
1965+
g_Options.m_dwTimerInterval = dwNewInterval;
1966+
g_Options.m_usUpdateSpeed = US_CUSTOM;
1967+
EndDialog(hwndDlg, IDOK);
1968+
break;
1969+
}
1970+
case IDCANCEL:
1971+
EndDialog(hwndDlg, IDCANCEL);
1972+
break;
1973+
}
1974+
return TRUE;
1975+
default:
1976+
return FALSE;
1977+
}
1978+
}
1979+
19171980
/*++ MainWnd_OnCommand
19181981
19191982
Routine Description:
@@ -2269,6 +2332,22 @@ void MainWnd_OnCommand(HWND hwnd, int id)
22692332
}
22702333
break;
22712334

2335+
case IDM_CUSTOM:
2336+
if (IDOK == DialogBoxParam(g_hInstance,
2337+
MAKEINTRESOURCE(IDD_CUSTOM_INTERVAL),
2338+
g_hMainWnd,
2339+
CustomIntervalDlgProc,
2340+
NULL))
2341+
{
2342+
KillTimer(g_hMainWnd, 0);
2343+
if (g_Options.m_dwTimerInterval)
2344+
{
2345+
SetTimer(g_hMainWnd, 0, g_Options.m_dwTimerInterval, NULL);
2346+
}
2347+
UpdateMenuStates();
2348+
}
2349+
break;
2350+
22722351
case IDM_ABOUT:
22732352
{
22742353
//

resource.h

+4
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@
269269
#define IDS_SHUTDOWN_REMOTE_OTHERUSERS 4051
270270
#define IDS_SHUTDOWN_OTHERUSERS 4052
271271
#define IDS_RESTART_OTHERUSERS 4053
272+
#define IDD_CUSTOM_INTERVAL 4054
273+
#define IDC_CUSTOM_INTERVAL_INPUT 4055
274+
#define IDC_CUSTOM_INTERVAL_SPINNER 4056
272275

273276
//
274277
// 5000-5999 reserved for dynamic creation of CPU graphs
@@ -410,6 +413,7 @@
410413
#define IDM_NORMAL 40023
411414
#define IDM_LOW 40024
412415
#define IDM_PAUSED 40025
416+
#define IDM_CUSTOM 40026
413417
#define IDM_PROC_DEBUG 40027
414418
#define IDM_PROC_TERMINATE 40028
415419

taskmgr.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ typedef enum
166166
US_NORMAL,
167167
US_LOW,
168168
US_PAUSED,
169+
US_CUSTOM,
169170
} UPDATESPEED;
170171
#define US_FIRST IDM_HIGH
171-
#define US_LAST IDM_PAUSED
172+
#define US_LAST IDM_CUSTOM
172173

173174

174175

taskmgr.rc

+25
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,25 @@ BEGIN
427427
PUSHBUTTON "&Help",ID_HELP,164,86,50,14
428428
END
429429

430+
IDD_CUSTOM_INTERVAL DIALOGEX 50, 50, 184, 70
431+
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
432+
CAPTION "Set Custom Update Interval"
433+
FONT 8, "MS Shell Dlg 2"
434+
BEGIN
435+
LTEXT "Input the amount of time, in milliseconds, that Task Manager should wait between updates.",
436+
-1,7,6,170,19
437+
EDITTEXT IDC_CUSTOM_INTERVAL_INPUT,58,30,68,12,ES_NUMBER
438+
439+
CONTROL "", IDC_CUSTOM_INTERVAL_SPINNER,
440+
UPDOWN_CLASS, WS_CHILD | WS_VISIBLE
441+
| UDS_SETBUDDYINT | UDS_AUTOBUDDY
442+
| UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,
443+
125, 30, 11, 12
444+
445+
DEFPUSHBUTTON "OK",IDOK,73,50,50,14,WS_GROUP
446+
PUSHBUTTON "Cancel",IDCANCEL,127,50,50,14
447+
END
448+
430449

431450
/////////////////////////////////////////////////////////////////////////////
432451
//
@@ -457,6 +476,7 @@ BEGIN
457476
MENUITEM "&Normal", IDM_NORMAL
458477
MENUITEM "&Low", IDM_LOW
459478
MENUITEM "&Paused", IDM_PAUSED
479+
MENUITEM "&Custom...", IDM_CUSTOM
460480
END
461481
MENUITEM SEPARATOR
462482
MENUITEM "Lar&ge Icons", IDM_LARGEICONS
@@ -560,6 +580,7 @@ BEGIN
560580
MENUITEM "&Normal", IDM_NORMAL
561581
MENUITEM "&Low", IDM_LOW
562582
MENUITEM "&Paused", IDM_PAUSED
583+
MENUITEM "&Custom...", IDM_CUSTOM
563584
END
564585
MENUITEM SEPARATOR
565586
POPUP "&CPU History"
@@ -608,6 +629,7 @@ BEGIN
608629
MENUITEM "&Normal", IDM_NORMAL
609630
MENUITEM "&Low", IDM_LOW
610631
MENUITEM "&Paused", IDM_PAUSED
632+
MENUITEM "&Custom...", IDM_CUSTOM
611633
END
612634
MENUITEM SEPARATOR
613635
MENUITEM "&Select Columns...", IDM_PROCCOLS
@@ -658,6 +680,7 @@ BEGIN
658680
MENUITEM "&Normal", IDM_NORMAL
659681
MENUITEM "&Low", IDM_LOW
660682
MENUITEM "&Paused", IDM_PAUSED
683+
MENUITEM "&Custom...", IDM_CUSTOM
661684
END
662685
MENUITEM SEPARATOR
663686
MENUITEM "&Select Columns...", IDM_USERCOLS
@@ -728,6 +751,7 @@ BEGIN
728751
MENUITEM "&Normal", IDM_NORMAL
729752
MENUITEM "&Low", IDM_LOW
730753
MENUITEM "&Paused", IDM_PAUSED
754+
MENUITEM "&Custom...", IDM_CUSTOM
731755
END
732756
MENUITEM SEPARATOR
733757
POPUP "&Network Adapter History"
@@ -902,6 +926,7 @@ BEGIN
902926
IDM_NORMAL "Updates the display every two seconds"
903927
IDM_LOW "Updates the display every four seconds"
904928
IDM_PAUSED "Display does not automatically update"
929+
IDM_CUSTOM "Set a custom update interval"
905930
IDM_PROC_DEBUG "Attaches the debugger to this process"
906931
IDM_PROC_TERMINATE "Removes the process from the system"
907932
IDM_PROC_REALTIME "Sets process to the REALTIME priority class"

0 commit comments

Comments
 (0)