Add accelerators
This commit is contained in:
parent
ecca252027
commit
489824b1f9
@ -31,3 +31,11 @@ BEGIN
|
|||||||
CTEXT "TIME", IDC_STATICTIME, 0, 20, 175, 25, SS_CENTERIMAGE
|
CTEXT "TIME", IDC_STATICTIME, 0, 20, 175, 25, SS_CENTERIMAGE
|
||||||
DEFPUSHBUTTON "STARTPAUSE" IDC_BUTTONSTARTPAUSE, 63, 50, 50, 15
|
DEFPUSHBUTTON "STARTPAUSE" IDC_BUTTONSTARTPAUSE, 63, 50, 50, 15
|
||||||
END
|
END
|
||||||
|
|
||||||
|
IDA_ACCELMAIN ACCELERATORS
|
||||||
|
BEGIN
|
||||||
|
"N", ID_FILE_NEW, CONTROL, VIRTKEY
|
||||||
|
"S", ID_FILE_SAVE, CONTROL, VIRTKEY
|
||||||
|
"S", ID_FILE_SAVEAS, CONTROL, SHIFT, VIRTKEY
|
||||||
|
"O", ID_FILE_OPEN, CONTROL, VIRTKEY
|
||||||
|
END
|
@ -4,7 +4,7 @@
|
|||||||
#include "resources.h"
|
#include "resources.h"
|
||||||
|
|
||||||
// Define window message to update the timer display
|
// Define window message to update the timer display
|
||||||
#define WM_UPDATEAPP WM_USER
|
#define WM_UPDATEAPP WM_USER + 1
|
||||||
|
|
||||||
// Enable visual styles
|
// Enable visual styles
|
||||||
#pragma comment(linker, "\"/manifestdependency:type='win32' \
|
#pragma comment(linker, "\"/manifestdependency:type='win32' \
|
||||||
@ -25,7 +25,14 @@ namespace mainspring {
|
|||||||
void Application::run() {
|
void Application::run() {
|
||||||
// Read last time here
|
// Read last time here
|
||||||
|
|
||||||
DialogBoxParam(nullptr, MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, reinterpret_cast<DLGPROC>(mainDlgProc), reinterpret_cast<LPARAM>(this));
|
HWND dlg = CreateDialogParam(nullptr, MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, reinterpret_cast<DLGPROC>(mainDlgProc), reinterpret_cast<LPARAM>(this));
|
||||||
|
|
||||||
|
HACCEL hAccel = LoadAccelerators(GetModuleHandle(NULL), MAKEINTRESOURCE(IDA_ACCELMAIN));
|
||||||
|
MSG msg = {};
|
||||||
|
ShowWindow(dlg, SW_SHOW);
|
||||||
|
while (GetMessage(&msg, nullptr, 0, 0))
|
||||||
|
if (!TranslateAccelerator(dlg, hAccel, &msg))
|
||||||
|
IsDialogMessage(dlg, &msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CALLBACK Application::mainDlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
BOOL CALLBACK Application::mainDlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||||
@ -57,7 +64,6 @@ namespace mainspring {
|
|||||||
SendMessage(GetDlgItem(dlg, IDC_STATICTIME), WM_SETFONT, reinterpret_cast<WPARAM>(timeFont), NULL);
|
SendMessage(GetDlgItem(dlg, IDC_STATICTIME), WM_SETFONT, reinterpret_cast<WPARAM>(timeFont), NULL);
|
||||||
|
|
||||||
SendMessage(dlg, WM_UPDATEAPP, NULL, NULL);
|
SendMessage(dlg, WM_UPDATEAPP, NULL, NULL);
|
||||||
|
|
||||||
SetTimer(dlg, 1, 50, nullptr);
|
SetTimer(dlg, 1, 50, nullptr);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -69,6 +75,31 @@ namespace mainspring {
|
|||||||
app->m_startpauseButtonPressed = true;
|
app->m_startpauseButtonPressed = true;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
case ID_FILE_NEW: {
|
||||||
|
std::cout << std::format("New!\n");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ID_FILE_SAVE: {
|
||||||
|
std::cout << std::format("Save!\n");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ID_FILE_SAVEAS: {
|
||||||
|
std::cout << std::format("Save As!\n");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ID_FILE_OPEN: {
|
||||||
|
std::cout << std::format("Open!\n");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ID_FILE_EXIT: {
|
||||||
|
SendMessage(dlg, WM_CLOSE, NULL, NULL);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
case ID_HELP_ABOUT:
|
case ID_HELP_ABOUT:
|
||||||
MessageBox(dlg, std::format("{} {}\nCopyright Grayson Riffe 2025\ngraysonriffe.com", app->m_appName, app->m_appVersion).c_str(), std::format("About {}", app->m_appName).c_str(), MB_OK);
|
MessageBox(dlg, std::format("{} {}\nCopyright Grayson Riffe 2025\ngraysonriffe.com", app->m_appName, app->m_appVersion).c_str(), std::format("About {}", app->m_appName).c_str(), MB_OK);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -109,7 +140,11 @@ namespace mainspring {
|
|||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
// TODO: Ask to / save time here
|
// TODO: Ask to / save time here
|
||||||
KillTimer(dlg, 1);
|
KillTimer(dlg, 1);
|
||||||
EndDialog(dlg, 0);
|
DestroyWindow(dlg);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
#define ID_HELP_ABOUT 311
|
#define ID_HELP_ABOUT 311
|
||||||
|
|
||||||
|
// Accelerators
|
||||||
|
#define IDA_ACCELMAIN 401
|
||||||
|
|
||||||
// Controls (text and buttons)
|
// Controls (text and buttons)
|
||||||
#define IDC_BUTTONSTARTPAUSE 1001
|
#define IDC_BUTTONSTARTPAUSE 1001
|
||||||
#define IDC_STATICTITLE 1002
|
#define IDC_STATICTITLE 1002
|
||||||
|
Loading…
x
Reference in New Issue
Block a user