diff --git a/WinChat/WinChat.rc b/WinChat/WinChat.rc index ba893cd..d64d2b2 100644 Binary files a/WinChat/WinChat.rc and b/WinChat/WinChat.rc differ diff --git a/WinChat/resource.h b/WinChat/resource.h index 6f8dc89..8e85634 100644 --- a/WinChat/resource.h +++ b/WinChat/resource.h @@ -7,6 +7,7 @@ #define IDC_STATICTITLE 1001 #define IDC_BUTTONEXIT 1003 #define IDC_BUTTONCONNECT 1005 +#define IDC_EDITADDRESS 1006 #define ID_FILE_EXIT 40001 #define ID_HELP_ABOUT 40002 @@ -16,7 +17,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 106 #define _APS_NEXT_COMMAND_VALUE 40003 -#define _APS_NEXT_CONTROL_VALUE 1006 +#define _APS_NEXT_CONTROL_VALUE 1007 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/WinChat/src/Application.cpp b/WinChat/src/Application.cpp index 303be68..58cb7c9 100644 --- a/WinChat/src/Application.cpp +++ b/WinChat/src/Application.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include "../resource.h" //This pragma enables visual styles, which makes dialogs and their controls look modern. @@ -12,15 +14,14 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") namespace wc { Application::Application(std::string& appName, std::string& appVersion) - : m_appName(appName) - , m_appVersion(appVersion) + : m_appName(appName.begin(), appName.end()) + , m_appVersion(appVersion.begin(), appVersion.end()) { - std::cout << std::format("{} {}", m_appName, m_appVersion); + std::wcout << std::format(L"{} {}", m_appName, m_appVersion); } void Application::run() { - HINSTANCE hInst = GetModuleHandle(NULL); - DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, (DLGPROC)dlgProc, reinterpret_cast(this)); + DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, (DLGPROC)dlgProc, reinterpret_cast(this)); } BOOL CALLBACK Application::dlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -30,40 +31,37 @@ namespace wc { case WM_INITDIALOG: { app = reinterpret_cast(lParam); - std::wstring appName(app->m_appName.begin(), app->m_appName.end()); - SetWindowText(dlg, appName.c_str()); + SetWindowText(dlg, app->m_appName.c_str()); POINT pt = { }; GetCursorPos(&pt); - HMONITOR mon = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); MONITORINFO mi = { }; mi.cbSize = sizeof(mi); - GetMonitorInfo(mon, &mi); - + GetMonitorInfo(MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST), &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()); - + SetDlgItemText(dlg, IDC_STATICTITLE, app->m_appName.c_str()); LOGFONT lFont = { }; lFont.lfHeight = 50; - HFONT font = CreateFontIndirect(&lFont); SendMessage(GetDlgItem(dlg, IDC_STATICTITLE), WM_SETFONT, reinterpret_cast(font), NULL); + SendDlgItemMessage(dlg, IDC_EDITADDRESS, EM_SETCUEBANNER, TRUE, reinterpret_cast(L"Address")); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { - case IDC_BUTTONCONNECT: - + case IDC_BUTTONCONNECT: { + std::wstring address; + address.resize(GetWindowTextLength(GetDlgItem(dlg, IDC_EDITADDRESS)) + 1); + GetDlgItemText(dlg, IDC_EDITADDRESS, address.data(), static_cast(address.size())); + MessageBox(dlg, std::format(L"Address: {}", address).c_str(), L"Alert", MB_OK); 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); + MessageBox(dlg, std::format(L"{} {}\nGrayson Riffe 2023", app->m_appName, app->m_appVersion).c_str(), L"About", MB_OK); return TRUE; } diff --git a/WinChat/src/Application.h b/WinChat/src/Application.h index 79d34dc..f3ac623 100644 --- a/WinChat/src/Application.h +++ b/WinChat/src/Application.h @@ -12,9 +12,10 @@ namespace wc { ~Application(); private: + static BOOL CALLBACK dlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam); - const std::string m_appName; - const std::string m_appVersion; + const std::wstring m_appName; + const std::wstring m_appVersion; }; } \ No newline at end of file