Add Chat
This commit is contained in:
		
							parent
							
								
									33b5740184
								
							
						
					
					
						commit
						5e6fe82bb3
					
				| @ -92,11 +92,13 @@ | ||||
|   </ItemDefinitionGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="src\Application.cpp" /> | ||||
|     <ClCompile Include="src\Chat.cpp" /> | ||||
|     <ClCompile Include="src\main.cpp" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="resource.h" /> | ||||
|     <ClInclude Include="src\Application.h" /> | ||||
|     <ClInclude Include="src\Chat.h" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ResourceCompile Include="WinChat.rc" /> | ||||
|  | ||||
| @ -21,6 +21,9 @@ | ||||
|     <ClCompile Include="src\Application.cpp"> | ||||
|       <Filter>Source Files</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="src\Chat.cpp"> | ||||
|       <Filter>Source Files</Filter> | ||||
|     </ClCompile> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="src\Application.h"> | ||||
| @ -29,6 +32,9 @@ | ||||
|     <ClInclude Include="resource.h"> | ||||
|       <Filter>Header Files</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="src\Chat.h"> | ||||
|       <Filter>Header Files</Filter> | ||||
|     </ClInclude> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ResourceCompile Include="WinChat.rc"> | ||||
|  | ||||
| @ -6,6 +6,7 @@ | ||||
| #include <CommCtrl.h> | ||||
| 
 | ||||
| #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<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) { | ||||
| @ -63,7 +80,9 @@ namespace wc { | ||||
| 						std::wstring screenname; | ||||
| 						screenname.resize(GetWindowTextLength(GetDlgItem(dlg, IDC_EDITSCREENNAME))); | ||||
| 						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; | ||||
| 					} | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										17
									
								
								WinChat/src/Chat.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								WinChat/src/Chat.cpp
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										17
									
								
								WinChat/src/Chat.h
									
									
									
									
									
										Normal 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: | ||||
| 
 | ||||
| 	}; | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user