diff --git a/WinChat/WinChat.rc b/WinChat/WinChat.rc
index d9cec9e..ba893cd 100644
Binary files a/WinChat/WinChat.rc and b/WinChat/WinChat.rc differ
diff --git a/WinChat/WinChat.vcxproj b/WinChat/WinChat.vcxproj
index c10d3f6..162b604 100644
--- a/WinChat/WinChat.vcxproj
+++ b/WinChat/WinChat.vcxproj
@@ -80,10 +80,11 @@
true
- Console
+ Windows
true
true
true
+ mainCRTStartup
PreBuild.bat
diff --git a/WinChat/resource.h b/WinChat/resource.h
index 11c7b92..6f8dc89 100644
--- a/WinChat/resource.h
+++ b/WinChat/resource.h
@@ -2,16 +2,21 @@
// Microsoft Visual C++ generated include file.
// Used by WinChat.rc
//
-#define IDD_MAINDIALOG 101
+#define IDD_DIALOGMAIN 101
+#define IDR_MENUMAIN 104
#define IDC_STATICTITLE 1001
+#define IDC_BUTTONEXIT 1003
+#define IDC_BUTTONCONNECT 1005
+#define ID_FILE_EXIT 40001
+#define ID_HELP_ABOUT 40002
// 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 1002
+#define _APS_NEXT_RESOURCE_VALUE 106
+#define _APS_NEXT_COMMAND_VALUE 40003
+#define _APS_NEXT_CONTROL_VALUE 1006
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/WinChat/src/Application.cpp b/WinChat/src/Application.cpp
index 839c019..303be68 100644
--- a/WinChat/src/Application.cpp
+++ b/WinChat/src/Application.cpp
@@ -1,28 +1,82 @@
#include "Application.h"
+#include
+#include
+
#include "../resource.h"
+//This pragma enables visual styles, which makes dialogs and their controls look modern.
+#pragma comment(linker,"\"/manifestdependency:type='win32' \
+name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
+processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
+
namespace wc {
Application::Application(std::string& appName, std::string& appVersion)
: m_appName(appName)
, m_appVersion(appVersion)
{
- std::printf("%s %s\n", m_appName.c_str(), m_appVersion.c_str());
+ std::cout << std::format("{} {}", m_appName, m_appVersion);
}
void Application::run() {
HINSTANCE hInst = GetModuleHandle(NULL);
- DialogBox(hInst, MAKEINTRESOURCE(IDD_MAINDIALOG), nullptr, (DLGPROC)dlgProc);
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, (DLGPROC)dlgProc, reinterpret_cast(this));
}
- BOOL CALLBACK Application::dlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
+ BOOL CALLBACK Application::dlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+ static Application* app = nullptr;
+
switch (msg) {
- case WM_INITDIALOG:
+ case WM_INITDIALOG: {
+ app = reinterpret_cast(lParam);
+
+ std::wstring appName(app->m_appName.begin(), app->m_appName.end());
+ SetWindowText(dlg, appName.c_str());
+
+ POINT pt = { };
+ GetCursorPos(&pt);
+ HMONITOR mon = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
+ MONITORINFO mi = { };
+ mi.cbSize = sizeof(mi);
+ GetMonitorInfo(mon, &mi);
+
+ SetWindowPos(dlg, nullptr, mi.rcMonitor.left + 100, mi.rcMonitor.top + 100, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+
+ SetDlgItemText(dlg, IDC_STATICTITLE, appName.c_str());
+
+ LOGFONT lFont = { };
+ lFont.lfHeight = 50;
+
+ HFONT font = CreateFontIndirect(&lFont);
+ SendMessage(GetDlgItem(dlg, IDC_STATICTITLE), WM_SETFONT, reinterpret_cast(font), NULL);
return TRUE;
+ }
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_BUTTONCONNECT:
+
+ return TRUE;
+
+ case ID_HELP_ABOUT: {
+ std::wstring appName(app->m_appName.begin(), app->m_appName.end());
+ std::wstring appVer(app->m_appVersion.begin(), app->m_appVersion.end());
+ std::wstring aboutStr = std::format(L"{} {}\nGrayson Riffe 2023", appName, appVer);
+ MessageBox(dlg, aboutStr.c_str(), L"About", MB_OK);
+ return TRUE;
+ }
+
+ case IDC_BUTTONEXIT:
+ case ID_FILE_EXIT:
+ PostMessage(dlg, WM_CLOSE, NULL, NULL);
+ return TRUE;
+ }
+
+ return FALSE;
case WM_CLOSE:
- EndDialog(hWnd, 0);
+ EndDialog(dlg, 0);
return TRUE;
}
diff --git a/WinChat/src/Application.h b/WinChat/src/Application.h
index e356928..79d34dc 100644
--- a/WinChat/src/Application.h
+++ b/WinChat/src/Application.h
@@ -12,7 +12,7 @@ namespace wc {
~Application();
private:
- static BOOL CALLBACK dlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+ static BOOL CALLBACK dlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam);
const std::string m_appName;
const std::string m_appVersion;