From c2b3518bdd7e2315c7852084f6c50854da18fcd7 Mon Sep 17 00:00:00 2001 From: Grayson Riffe Date: Fri, 29 Sep 2023 13:36:08 -0500 Subject: [PATCH] Start chat dialog --- WinChat/WinChat.rc | Bin 8108 -> 9492 bytes WinChat/resource.h | 9 +++++++-- WinChat/src/Chat.cpp | 22 ++++++++++++++++++++++ WinChat/src/Chat.h | 1 + 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/WinChat/WinChat.rc b/WinChat/WinChat.rc index b3debbaeaffc52a347aae901ef5346725cf310b7..6286a4fd81556eefa7294d24a1f9267f25a49f65 100644 GIT binary patch delta 365 zcmZ2uKgDZ-(BxfwVyqqvjtn7_AMz>k8#9;!p$>xrgAs!{gVE%Aj>m$|3}AVN5C%^m z_F-_H{E|O?avhg}DonFqxdsZOZP#kjYTYkUUwFTUFl$Xmc=wGlM@+j~`H{ zGuS3021|6EKywU%`U|;ibzyFU=nVk6+mRs>C=YTU2!m{exY2~cVDfD)d1(cP8lb;j zfi}f61OaJBp!+~J`Y=RJRumWBBs7D0a+-(|G_+=lG_!)tu$ZhU8p~<~G}Cl*qo^(u Ra)62jPZHX&IZncl9RMIqL?i$J delta 29 kcmbQ@wZ?vd(BusEO`BW9o-u8nBqhcKn+a diff --git a/WinChat/resource.h b/WinChat/resource.h index 347b243..2a8ba86 100644 --- a/WinChat/resource.h +++ b/WinChat/resource.h @@ -6,6 +6,7 @@ #define IDR_MENUMAIN 104 #define IDI_ICONMAIN 106 #define IDD_DIALOGCONNECTING 107 +#define IDD_DIALOGCHAT 109 #define IDC_STATICTITLE 1001 #define IDC_BUTTONEXIT 1003 #define IDC_BUTTONCONNECT 1005 @@ -15,6 +16,10 @@ #define IDC_STATICDESC 1009 #define IDC_STATICADDRESS 1010 #define IDC_PROGRESS 1011 +#define IDC_EDITCHATDISPLAY 1012 +#define IDC_EDITCHATINPUT 1013 +#define IDC_BUTTONSEND 1014 +#define IDC_BUTTONDISCONNECT 1015 #define ID_FILE_EXIT 40001 #define ID_HELP_ABOUT 40002 @@ -22,9 +27,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 109 +#define _APS_NEXT_RESOURCE_VALUE 111 #define _APS_NEXT_COMMAND_VALUE 40003 -#define _APS_NEXT_CONTROL_VALUE 1012 +#define _APS_NEXT_CONTROL_VALUE 1016 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/WinChat/src/Chat.cpp b/WinChat/src/Chat.cpp index 45bc9a8..14b08b6 100644 --- a/WinChat/src/Chat.cpp +++ b/WinChat/src/Chat.cpp @@ -29,6 +29,10 @@ namespace wc { ConnDlgInput* input = new ConnDlgInput{ this, xPos, yPos }; DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOGCONNECTING), nullptr, reinterpret_cast(connDlgProc), reinterpret_cast(input)); + //If we're connected, open the chat window + if (m_connected) + DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOGCHAT), nullptr, reinterpret_cast(chatDlgProc), reinterpret_cast(this)); + netThread.join(); } @@ -127,6 +131,24 @@ namespace wc { return FALSE; } + BOOL CALLBACK Chat::chatDlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) { + static Chat* chat = nullptr; + + switch (msg) { + case WM_INITDIALOG: + chat = reinterpret_cast(lParam); + SetWindowText(dlg, std::format(L"remote screenname at {} - WinChat", chat->m_address).c_str()); + SendMessage(dlg, WM_SETICON, ICON_BIG, reinterpret_cast(LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICONMAIN)))); + return TRUE; + + case WM_CLOSE: + EndDialog(dlg, 0); + return TRUE; + } + + return FALSE; + } + Chat::~Chat() { diff --git a/WinChat/src/Chat.h b/WinChat/src/Chat.h index 9d084eb..9a8d74b 100644 --- a/WinChat/src/Chat.h +++ b/WinChat/src/Chat.h @@ -15,6 +15,7 @@ namespace wc { void runNetThread(); std::wstring getErrorString(); static BOOL CALLBACK connDlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam); + static BOOL CALLBACK chatDlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam); const std::wstring m_address; const std::wstring m_screenname;