diff --git a/WinChat/WinChat.vcxproj b/WinChat/WinChat.vcxproj index 70d6764..bda78f1 100644 --- a/WinChat/WinChat.vcxproj +++ b/WinChat/WinChat.vcxproj @@ -92,11 +92,13 @@ + + diff --git a/WinChat/WinChat.vcxproj.filters b/WinChat/WinChat.vcxproj.filters index 55f74f8..fc05d7b 100644 --- a/WinChat/WinChat.vcxproj.filters +++ b/WinChat/WinChat.vcxproj.filters @@ -21,6 +21,9 @@ Source Files + + Source Files + @@ -29,6 +32,9 @@ Header Files + + Header Files + diff --git a/WinChat/src/Application.cpp b/WinChat/src/Application.cpp index 3a338c9..6e76070 100644 --- a/WinChat/src/Application.cpp +++ b/WinChat/src/Application.cpp @@ -6,6 +6,7 @@ #include #include "../resource.h" +#include "Chat.h" //This pragma enables visual styles, which makes dialogs and their controls look modern. #pragma comment(linker,"\"/manifestdependency:type='win32' \ @@ -13,6 +14,11 @@ name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") namespace wc { + struct MainDlgOutput { + std::wstring address; + std::wstring screenname; + }; + Application::Application(std::string& appName, std::string& appVersion) : m_appName(appName.begin(), appName.end()) , m_appVersion(appVersion.begin(), appVersion.end()) @@ -21,7 +27,18 @@ namespace wc { } void Application::run() { - DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, (DLGPROC)mainDlgProc, reinterpret_cast(this)); + //First, run the main dialog to get needed input... + INT_PTR result = NULL; + while (result = DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, (DLGPROC)mainDlgProc, reinterpret_cast(this))) { + MainDlgOutput* output = reinterpret_cast(result); + const auto [address, screenname] = *output; + delete output; + + { + Chat chat(address, screenname); + chat.run(); + } + } } BOOL CALLBACK Application::mainDlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -63,7 +80,9 @@ namespace wc { 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); + + MainDlgOutput* out = new MainDlgOutput{ address, screenname }; + EndDialog(dlg, reinterpret_cast(out)); return TRUE; } diff --git a/WinChat/src/Chat.cpp b/WinChat/src/Chat.cpp new file mode 100644 index 0000000..b87c2f3 --- /dev/null +++ b/WinChat/src/Chat.cpp @@ -0,0 +1,17 @@ +#include "Chat.h" + +#include + +namespace wc { + Chat::Chat(std::wstring address, std::wstring screenname) { + MessageBox(nullptr, std::format(L"Address: {}\nScreen Name: {}", address, screenname).c_str(), L"Alert", MB_OK); + } + + void Chat::run() { + + } + + Chat::~Chat() { + + } +} \ No newline at end of file diff --git a/WinChat/src/Chat.h b/WinChat/src/Chat.h new file mode 100644 index 0000000..14fc9f6 --- /dev/null +++ b/WinChat/src/Chat.h @@ -0,0 +1,17 @@ +#pragma once +#include + +#include + +namespace wc { + class Chat { + public: + Chat(std::wstring address, std::wstring screenname); + + void run(); + + ~Chat(); + private: + + }; +} \ No newline at end of file