This commit is contained in:
Grayson Riffe 2023-09-04 18:41:41 -05:00
parent 33b5740184
commit 5e6fe82bb3
5 changed files with 63 additions and 2 deletions

View File

@ -92,11 +92,13 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="src\Application.cpp" /> <ClCompile Include="src\Application.cpp" />
<ClCompile Include="src\Chat.cpp" />
<ClCompile Include="src\main.cpp" /> <ClCompile Include="src\main.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="src\Application.h" /> <ClInclude Include="src\Application.h" />
<ClInclude Include="src\Chat.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="WinChat.rc" /> <ResourceCompile Include="WinChat.rc" />

View File

@ -21,6 +21,9 @@
<ClCompile Include="src\Application.cpp"> <ClCompile Include="src\Application.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\Chat.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="src\Application.h"> <ClInclude Include="src\Application.h">
@ -29,6 +32,9 @@
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\Chat.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="WinChat.rc"> <ResourceCompile Include="WinChat.rc">

View File

@ -6,6 +6,7 @@
#include <CommCtrl.h> #include <CommCtrl.h>
#include "../resource.h" #include "../resource.h"
#include "Chat.h"
//This pragma enables visual styles, which makes dialogs and their controls look modern. //This pragma enables visual styles, which makes dialogs and their controls look modern.
#pragma comment(linker,"\"/manifestdependency:type='win32' \ #pragma comment(linker,"\"/manifestdependency:type='win32' \
@ -13,6 +14,11 @@ name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
namespace wc { namespace wc {
struct MainDlgOutput {
std::wstring address;
std::wstring screenname;
};
Application::Application(std::string& appName, std::string& appVersion) Application::Application(std::string& appName, std::string& appVersion)
: m_appName(appName.begin(), appName.end()) : m_appName(appName.begin(), appName.end())
, m_appVersion(appVersion.begin(), appVersion.end()) , m_appVersion(appVersion.begin(), appVersion.end())
@ -21,7 +27,18 @@ namespace wc {
} }
void Application::run() { void Application::run() {
DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, (DLGPROC)mainDlgProc, reinterpret_cast<LPARAM>(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<LPARAM>(this))) {
MainDlgOutput* output = reinterpret_cast<MainDlgOutput*>(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) { BOOL CALLBACK Application::mainDlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) {
@ -63,7 +80,9 @@ namespace wc {
std::wstring screenname; std::wstring screenname;
screenname.resize(GetWindowTextLength(GetDlgItem(dlg, IDC_EDITSCREENNAME))); screenname.resize(GetWindowTextLength(GetDlgItem(dlg, IDC_EDITSCREENNAME)));
GetDlgItemText(dlg, IDC_EDITSCREENNAME, screenname.data(), static_cast<int>(screenname.size() + 1)); GetDlgItemText(dlg, IDC_EDITSCREENNAME, screenname.data(), static_cast<int>(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<INT_PTR>(out));
return TRUE; return TRUE;
} }

17
WinChat/src/Chat.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "Chat.h"
#include <format>
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() {
}
}

17
WinChat/src/Chat.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#include <string>
#include <Windows.h>
namespace wc {
class Chat {
public:
Chat(std::wstring address, std::wstring screenname);
void run();
~Chat();
private:
};
}