diff --git a/WinChat/WinChat.rc b/WinChat/WinChat.rc index 26b9356..9535158 100644 Binary files a/WinChat/WinChat.rc and b/WinChat/WinChat.rc differ 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;