From 33b5740184dbd44da4c2f896877d3be140d24f4e Mon Sep 17 00:00:00 2001 From: Grayson Riffe Date: Mon, 4 Sep 2023 16:55:24 -0500 Subject: [PATCH] Rearrange main dialog and add screen name --- WinChat/WinChat.rc | Bin 6276 -> 6816 bytes WinChat/resource.h | 4 +++- WinChat/src/Application.cpp | 16 +++++++++++----- WinChat/src/Application.h | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/WinChat/WinChat.rc b/WinChat/WinChat.rc index 26b93569b4cdf59661d630daa3a7c996a2a2da6d..953515857615692e0468923ef5a48027c9f157a7 100644 GIT binary patch delta 416 zcmaKoF-yZx6opSHl9<<8L`0mdivcfyaIK9lm?sebCRHms_XlBg7F7(1L~!KfiZgt@Q|9wjy{uH5JOx z)$+CKwG+e`VL+WzeGFL{r}1~u`{Q4zpt^hT<=ssinuGkpVLF#;YFBgQO=T+)Up$HH zfn2No%@`SOs1#S2Gu)i_V|i5D9h1mV%5*^yzU(AOFlIiJ?SkhBXUx~fDF!l8hg%6* zcO<6dw&%`c Zs)by|Y;9cA=!mtkD|_~5{?UALegKFCNEiSB delta 154 zcmZ2r+G4n&fP>$d!GOV-L5D$s!H~g>!DMqi$6iK3O9peGkOhMYkTe8BqshKphLhR2 zqqr>@jKE?h3?`HBa!XEb;r8J*0;)4Z63ykb1oKT8EG7r?C?G!F+O{i1=nU!C9OD9eyBA diff --git a/WinChat/resource.h b/WinChat/resource.h index cb2a82a..7e418c0 100644 --- a/WinChat/resource.h +++ b/WinChat/resource.h @@ -10,6 +10,8 @@ #define IDC_BUTTONCONNECT 1005 #define IDC_EDITADDRESS 1006 #define IDC_ICONMAIN 1007 +#define IDC_EDITSCREENNAME 1008 +#define IDC_STATICDESC 1009 #define ID_FILE_EXIT 40001 #define ID_HELP_ABOUT 40002 @@ -19,7 +21,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 107 #define _APS_NEXT_COMMAND_VALUE 40003 -#define _APS_NEXT_CONTROL_VALUE 1008 +#define _APS_NEXT_CONTROL_VALUE 1010 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/WinChat/src/Application.cpp b/WinChat/src/Application.cpp index c3d0458..3a338c9 100644 --- a/WinChat/src/Application.cpp +++ b/WinChat/src/Application.cpp @@ -21,10 +21,10 @@ namespace wc { } void Application::run() { - DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, (DLGPROC)dlgProc, reinterpret_cast(this)); + DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, (DLGPROC)mainDlgProc, reinterpret_cast(this)); } - BOOL CALLBACK Application::dlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) { + BOOL CALLBACK Application::mainDlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) { static Application* app = nullptr; switch (msg) { @@ -47,7 +47,10 @@ namespace wc { HFONT font = CreateFontIndirect(&lFont); SendMessage(GetDlgItem(dlg, IDC_STATICTITLE), WM_SETFONT, reinterpret_cast(font), NULL); + SetDlgItemText(dlg, IDC_STATICDESC, L"A simple Windows chat app"); + SendDlgItemMessage(dlg, IDC_EDITADDRESS, EM_SETCUEBANNER, TRUE, reinterpret_cast(L"Address")); + SendDlgItemMessage(dlg, IDC_EDITSCREENNAME, EM_SETCUEBANNER, TRUE, reinterpret_cast(L"User")); return TRUE; } @@ -55,9 +58,12 @@ namespace wc { switch (LOWORD(wParam)) { 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); + address.resize(GetWindowTextLength(GetDlgItem(dlg, IDC_EDITADDRESS))); + GetDlgItemText(dlg, IDC_EDITADDRESS, address.data(), static_cast(address.size() + 1)); + std::wstring screenname; + screenname.resize(GetWindowTextLength(GetDlgItem(dlg, IDC_EDITSCREENNAME))); + GetDlgItemText(dlg, IDC_EDITSCREENNAME, screenname.data(), static_cast(screenname.size() + 1)); + MessageBox(dlg, std::format(L"Address: {}\nScreen Name: {}", address, screenname).c_str(), L"Alert", MB_OK); return TRUE; } diff --git a/WinChat/src/Application.h b/WinChat/src/Application.h index f3ac623..f571e16 100644 --- a/WinChat/src/Application.h +++ b/WinChat/src/Application.h @@ -13,7 +13,7 @@ namespace wc { ~Application(); private: - static BOOL CALLBACK dlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam); + static BOOL CALLBACK mainDlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam); const std::wstring m_appName; const std::wstring m_appVersion;