Add base dialog

This commit is contained in:
grayson committed 2026-06-04 18:08:26 -05:00
1 parent fdbe1a07bb
commit 1d3e58587d
7 files changed
+220 -3

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
// Application class implementation
#include "pch.h"
#include "Application.h"
#include "resource.h"
namespace watchfuleye {
Application::Application(const char* appName, const char* appVersion)
: m_appName(appName)
, m_appVersion(appVersion)
, m_mainDlg(nullptr)
{
std::cout << std::format("{} {}\n", m_appName, m_appVersion);
}
void Application::run() {
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
m_mainDlg = CreateDialogParam(nullptr, MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, reinterpret_cast<DLGPROC>(mainDlgProc), reinterpret_cast<LPARAM>(this));
ShowWindow(m_mainDlg, SW_SHOW);
MSG msg = {};
while (GetMessage(&msg, nullptr, 0, 0))
IsDialogMessage(m_mainDlg, &msg);
}
BOOL CALLBACK Application::mainDlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) {
static Application* app = nullptr;
switch (msg) {
case WM_INITDIALOG: {
app = reinterpret_cast<Application*>(lParam);
SetWindowText(dlg, app->m_appName.c_str());
// Set window icons
// Spawn in the lower right corner of the virtual screen (might be problematic in some cases)
int cornerX = GetSystemMetrics(SM_XVIRTUALSCREEN) + GetSystemMetrics(SM_CXVIRTUALSCREEN);
int cornerY = GetSystemMetrics(SM_YVIRTUALSCREEN) + GetSystemMetrics(SM_CYVIRTUALSCREEN);
SetWindowPos(dlg, nullptr, cornerX - 550, cornerY - 340, NULL, NULL, SWP_NOZORDER | SWP_NOSIZE);
return TRUE;
}
case WM_CLOSE: {
// Do nothing
return TRUE;
}
case WM_DESTROY: {
PostQuitMessage(0);
return TRUE;
}
}
return FALSE;
}
Application::~Application() {
}
}
+17
View File
@@ -0,0 +1,17 @@
// Application class header
namespace watchfuleye {
class Application {
public:
Application(const char* appName, const char* appVersion);
void run();
~Application();
private:
static BOOL CALLBACK mainDlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam);
std::string m_appName, m_appVersion;
HWND m_mainDlg;
};
}
+12 -2
View File
@@ -2,10 +2,20 @@
#include "pch.h"
#include "version.h"
#include "Application.h"
// Enable visual styles
#pragma comment(linker, "\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#define APPNAME "Watchful Eye"
int main(int argc, char* argv[]) {
std::cout << "Watchful Eye " APPVERSION "\n";
{
watchfuleye::Application app(APPNAME, APPVERSION);
app.run();
}
std::cin.get();
return EXIT_SUCCESS;
}
+18
View File
@@ -0,0 +1,18 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by C:\Users\Grayson\Documents\Visual Studio 18\Solutions\watchful-eye\WatchfulEye\resource.rc
//
#define IDD_DIALOGMAIN 101
#define IDC_STATICTIME 1000
#define IDC_STATICUPPER 1001
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif