no message

This commit is contained in:
zcy 2022-01-13 01:37:24 +08:00
parent 8a1cc7a1c8
commit 511f3432b4
11 changed files with 68 additions and 39 deletions

View File

@ -15,8 +15,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
AllocConsole();
freopen("CONOUT$", "w", stdout);
//AllocConsole();
//freopen("CONOUT$", "w", stdout);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);

View File

@ -42,7 +42,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120_xp</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
@ -203,6 +203,15 @@
<ProjectReference Include="..\..\ui_components\ui_components.vcxproj">
<Project>{0149ba6e-3c0a-426d-aa0a-0b9ec7742f19}</Project>
</ProjectReference>
<ProjectReference Include="..\layouts\layouts.vcxproj">
<Project>{2bffa1ee-039d-479e-9bcc-2d12f8aedd16}</Project>
</ProjectReference>
<ProjectReference Include="..\richlist\richlist.vcxproj">
<Project>{878f5bf0-652a-4fdb-992b-bb7f26d62f0d}</Project>
</ProjectReference>
<ProjectReference Include="..\VirtualBox\VirtualBox.vcxproj">
<Project>{e35589c6-9509-4116-996f-1d045c2dacae}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -1,5 +1,4 @@
#include "stdafx.h"
#include "controls_form.h"
#include "Utils\DpiManager.h"
#include <fstream>

View File

@ -4,7 +4,6 @@
#include "stdafx.h"
#include "main.h"
#include "controls_form.h"
#include "Utils\DpiManager.h"
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
@ -12,8 +11,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
AllocConsole();
freopen("CONOUT$", "w", stdout);
//AllocConsole();
//freopen("CONOUT$", "w", stdout);
auto dpiManager = ui::DpiManager::GetInstance();
dpiManager->SetAdaptDPI(); // 设置适配自动dpi

View File

@ -42,7 +42,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120_xp</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">

View File

@ -130,8 +130,7 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
auto key = info->ip + L":" + std::to_wstring(info->port);
node->SetText(key);
node->SetClass(L"listitem");
node->SetFixedHeight(20);
node->SetMargin({ 20, 0, 0, 0 });
std::cout << "node heigjt" << node->GetHeight();
mMonitor->GetRootNode()->GetChildNode(2)->AddChildNode(node);
gTcpServerCnt++;
@ -189,8 +188,7 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
ui::TreeNode* node = new ui::TreeNode;
node->SetText(p->name);
node->SetClass(L"listitem");
node->SetFixedHeight(20);
node->SetMargin({ 20, 0, 0, 0 });
mMonitor->GetRootNode()->GetChildNode(0)->AddChildNode(node);
if (mUartForm.find(p->name) == mUartForm.end()) {
@ -255,48 +253,45 @@ void BasicForm::InitWindow(){
});
}
mMonitor = dynamic_cast<ui::TreeView*>(FindControl(L"tree"));
mMonitor->SetClass(L"list");
mMonitor->SetIndent(5);
if (nullptr != mMonitor) {
ui::TreeNode* node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"uart"));
node->SetClass(L"listitem");
node->SetFixedHeight(20);
node->SetMargin({ 10, 0, 0, 0 });
mMonitor->GetRootNode()->AddChildNode(node);
node->SetClass(L"list_topitem");
node->SetFixedHeight(30);
mMonitor->GetRootNode()->AddChildNode(node);
node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"tcp client"));
node->SetClass(L"listitem");
node->SetFixedHeight(20);
node->SetMargin({ 10, 0, 0, 0 });
node->SetClass(L"list_topitem");
node->SetFixedHeight(30);
mMonitor->GetRootNode()->AddChildNode(node);
node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"tcp server"));
node->SetClass(L"listitem");
node->SetFixedHeight(20);
node->SetMargin({ 10, 0, 0, 0 });
node->SetClass(L"list_topitem");
node->SetFixedHeight(30);
mMonitor->GetRootNode()->AddChildNode(node);
node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"udp client"));
node->SetClass(L"listitem");
node->SetFixedHeight(20);
node->SetMargin({ 10, 0, 0, 0 });
node->SetClass(L"list_topitem");
node->SetFixedHeight(30);
mMonitor->GetRootNode()->AddChildNode(node);
node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"udp server"));
node->SetClass(L"listitem");
node->SetFixedHeight(20);
node->SetMargin({ 10, 0, 0, 0 });
node->SetClass(L"list_topitem");
node->SetFixedHeight(30);
mMonitor->GetRootNode()->AddChildNode(node);
node = new ui::TreeNode;
node->SetText(nbase::StringPrintf(L"udp group"));
node->SetClass(L"listitem");
node->SetFixedHeight(20);
node->SetMargin({ 10, 0, 0, 0 });
node->SetClass(L"list_topitem");
mMonitor->GetRootNode()->AddChildNode(node);
}

View File

@ -192,9 +192,9 @@
<Xml Include="..\Debug\resources\themes\default\basic\basic.xml" />
<Xml Include="..\Debug\resources\themes\default\basic\newmonitor.xml" />
<Xml Include="..\Debug\resources\themes\default\basic\uart_form.xml" />
<Xml Include="..\Debug\resources\themes\default\global.xml" />
<Xml Include="..\x64\Debug\resources\themes\default\basic\tcp_form.xml" />
<Xml Include="..\x64\Debug\resources\themes\default\basic\tcp_server_form.xml" />
<Xml Include="x64\Debug\themes\default\global.xml" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="proto_debuger.rc" />

View File

@ -88,9 +88,6 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
<Xml Include="..\Debug\resources\themes\default\global.xml">
<Filter>资源文件</Filter>
</Xml>
<Xml Include="..\Debug\resources\themes\default\basic\basic.xml">
<Filter>资源文件</Filter>
</Xml>
@ -106,6 +103,9 @@
<Xml Include="..\x64\Debug\resources\themes\default\basic\tcp_server_form.xml">
<Filter>资源文件</Filter>
</Xml>
<Xml Include="x64\Debug\themes\default\global.xml">
<Filter>资源文件</Filter>
</Xml>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="proto_debuger.rc">

View File

@ -84,8 +84,13 @@ void TcpServerFrom::OnNewConnAccept(ConnectionLibevent* p)
element->SetTextPadding({ 6,0,6,0 });
element->SetText(std::to_wstring(p->SocketFd()));
mClients[p->SocketFd()] = p;
m_combo_1->Add(element);
p->SetRecvHandler(
[this](char* p, uint32_t len) {
std::cout << "SetRecvHandler " << p;
}
);
return;
}

View File

@ -8,6 +8,11 @@ extern "C" {
#include "event2/thread.h"
};
void defaultConnRead(char* p, uint32_t len) {
std::cout << p;
return;
}
class ServerCallbacks {
public:
@ -19,7 +24,8 @@ ConnectionLibevent::ConnectionLibevent(TcpServerLibevent* p, struct bufferevent*
m_parent_server(nullptr),
m_event(nullptr),
m_fd(-1),
m_addr(nullptr)
m_addr(nullptr),
m_recv_handle(defaultConnRead)
{
m_parent_server = p;
m_event = ev;
@ -50,8 +56,13 @@ void defaultConnClose(ConnectionLibevent*p) {
}
int ConnectionLibevent::OnRecv(char* p, uint32_t len) {
std::cout << "OnRecv " << p << std::endl;
if (m_recv_handle != nullptr) {
(m_recv_handle)(p, len);
}
m_bytes_recv += len;
return 0;
}
@ -82,6 +93,12 @@ int ConnectionLibevent::Close() {
}
return 0;
}
int ConnectionLibevent::SetRecvHandler(OnRecvHandle p) {
if (nullptr == p)
return -1;
this->m_recv_handle = p;
return 0;
}
int ConnectionLibevent::SetServer(TcpServerLibevent* p) {
if (nullptr != p) {
@ -271,6 +288,8 @@ int TcpServerLibevent::SetConnectionLeaveHandle(OnDisconnect p) {
return 0;
}
/**
* @description:
* @param {int} ports

View File

@ -35,11 +35,13 @@ public:
uint32_t fd,
struct sockaddr_in* p1);
typedef std::function<void (char* p, uint32_t len)> OnRecvHandle;
virtual int OnRecv(char* p, uint32_t len); // data ready callback
virtual int OnClose(); // close callback
virtual int OnWrite(); // write data done callback
int WriteData(const char* p, uint16_t len);
int SetServer(TcpServerLibevent*);
int SetRecvHandler(OnRecvHandle);
TcpServerLibevent* Server();
string IpAddress();
uint32_t SocketFd();
@ -51,6 +53,7 @@ private:
struct bufferevent* m_event;
struct sockaddr_in* m_addr;
uint32_t m_fd;
OnRecvHandle m_recv_handle;
};
// 管理服务端