Skip to content

Commit

Permalink
Expanded Min & Max interval values, with constexpr defs
Browse files Browse the repository at this point in the history
  • Loading branch information
shriprem committed Sep 26, 2024
1 parent 3313591 commit 6fcc1a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions StayAwake/StayAwakeDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ BOOL CStayAwakeDlg::OnInitDialog()
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

Utils::addTooltip(theApp.m_hInstance, m_hWnd, IDC_INTERVAL, L"", L"Number between 30 and 3600", 3, TRUE);
Utils::addTooltip(theApp.m_hInstance, m_hWnd, IDC_INTERVAL, L"",
wstring{ L"Number between " } + to_wstring(MIN_PERIOD) + L" and " + to_wstring(MAX_PERIOD), 3, TRUE);
Utils::addTooltip(theApp.m_hInstance, m_hWnd, IDC_ABOUT_BUTTON, L"", L"About StayAwake", 3, TRUE);
Utils::loadBitmap(theApp.m_hInstance, m_hWnd, IDC_ABOUT_BUTTON, IDB_ABOUT_BITMAP);

Expand Down Expand Up @@ -148,9 +149,10 @@ void CStayAwakeDlg::OnKillfocusInterval()

nInterval = GetDlgItemInt(IDC_INTERVAL, nullptr, FALSE);

if (nInterval < 30 || nInterval > 3600)
if (nInterval < MIN_PERIOD || nInterval > MAX_PERIOD)
{
Utils::showEditBalloonTip(GetDlgItem(IDC_INTERVAL)->m_hWnd, L"Timer Interval in seconds", L"Please enter a value between 30 and 3600");
Utils::showEditBalloonTip(GetDlgItem(IDC_INTERVAL)->m_hWnd, L"Timer Interval in seconds",
(wstring{ L"Please enter a value between " } + to_wstring(MIN_PERIOD) + L" and " + to_wstring(MAX_PERIOD)).c_str());
SetDlgItemInt(IDC_INTERVAL, m_TimerSeconds, FALSE);
return;
}
Expand Down
2 changes: 2 additions & 0 deletions StayAwake/StayAwakeDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ constexpr auto PREF_DEFAULTS = L"Defaults";
constexpr auto PREF_MULTI_INSTANCE = L"MultipleInstancesAllowed";
constexpr auto PREF_TIMER_INTERVAL = L"TimerIntervalInSeconds";

constexpr auto MIN_PERIOD{ 10 };
constexpr auto MAX_PERIOD{ 9990 };

class CStayAwakeDlg : public CDialogEx
{
Expand Down

0 comments on commit 6fcc1a2

Please sign in to comment.