diff --git a/WinChat/WinChat.rc b/WinChat/WinChat.rc index b3debba..6286a4f 100644 Binary files a/WinChat/WinChat.rc and b/WinChat/WinChat.rc differ 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;