From e44f576a7957670344d96a72f43c032427b08ea4 Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Sat, 19 Feb 2022 00:53:51 +0800 Subject: [PATCH] no message --- examples/proto_debuger/base_form.cpp | 19 +++++++++++++++++++ examples/proto_debuger/tcp_client_form.cpp | 1 - examples/proto_debuger/tcp_server_form.cpp | 12 +++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/examples/proto_debuger/base_form.cpp b/examples/proto_debuger/base_form.cpp index 486489ed..d8c49a06 100644 --- a/examples/proto_debuger/base_form.cpp +++ b/examples/proto_debuger/base_form.cpp @@ -105,7 +105,26 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) delete mRightShow; mRightShow = nullptr; } + if (uMsg == WM_USER_TCP_SERVER_CLOSE) { + wprintf(L"close %s\r\n", ((wstring*)wParam)->c_str()); + mRightShow->SetVisible(false); + mRightSide->SetAutoDestroy(true); + mRightSide->RemoveAll(); + mTcpServerForm.erase(*(wstring*)(wParam)); + int cnt = mMonitor->GetRootNode()->GetChildNode(2)->GetChildNodeCount(); + ui::TreeNode* p = nullptr; + for (int i = 0; i < cnt; i++) { + if (mMonitor->GetRootNode()->GetChildNode(2)->GetChildNode(i)->GetText() + == *(wstring*)(wParam)) { + p = mMonitor->GetRootNode()->GetChildNode(2)->GetChildNode(i); + break; + } + } + mMonitor->GetRootNode()->GetChildNode(2)->RemoveChildNode(p); + delete mRightShow; + mRightShow = nullptr; + } if (uMsg == WM_USER_POS_CHANGED) { } diff --git a/examples/proto_debuger/tcp_client_form.cpp b/examples/proto_debuger/tcp_client_form.cpp index aeb311b8..c5c7d822 100644 --- a/examples/proto_debuger/tcp_client_form.cpp +++ b/examples/proto_debuger/tcp_client_form.cpp @@ -74,7 +74,6 @@ void TcpClientForm::Init() WM_USER_TCP_CLIENT_CLOSE, (WPARAM)name, 0); return true; }); - } m_btn_send_data->AttachAllEvents([this](ui::EventArgs* ev) { diff --git a/examples/proto_debuger/tcp_server_form.cpp b/examples/proto_debuger/tcp_server_form.cpp index 1f69143d..80773b5d 100644 --- a/examples/proto_debuger/tcp_server_form.cpp +++ b/examples/proto_debuger/tcp_server_form.cpp @@ -2,7 +2,7 @@ #include "utils.h" #include #include "lua_bind.h" - +#include "msgdef.h" extern "C" { #include "event2/bufferevent.h" #include "event2/buffer.h" @@ -80,6 +80,16 @@ void TcpServerFrom::Init() m_button_3 = dynamic_cast(FindSubControl(L"btn_do_lua")); m_btn_save_lua = dynamic_cast(FindSubControl(L"btn_save_lua")); + if (m_button_2 != nullptr) { + m_button_2->AttachClick([this](ui::EventArgs* ev) { + wstring* name = new wstring(this->GetName()); + ::PostMessage(this->GetWindow()->GetHWND(), + WM_USER_TCP_SERVER_CLOSE, (WPARAM)name, 0); + + return true; + }); + } + if (nullptr != m_button_1) { m_button_1->AttachClick([this](ui::EventArgs* ev) { auto client = m_combo_1->GetText();