CClientLog was the only sub-connection dialog without ON_WM_CLOSE, so the close button did nothing and the window stayed until the master exited. It now wires WM_CLOSE like the other dialogs: it detaches the context's dialog pointer and cancels the log sub-connection before destroying, so the client's three-second log push loop stops instead of posting increments to a destroyed window. Every menu click also opened a new dialog and a new log sub-connection: the client starts one per COMMAND_QUERY_LOG, and each arrives on a new context whose hDlg is empty, so the existing "append to open dialog" path never matched. The master now keeps one log window per client id; a repeat request closes the previous sub-connection, rebinds the window to the new one and refreshes the snapshot instead of opening another. Verified on the Debug server: WM_CLOSE destroys the window, two extra clicks keep a single window, and the main connection stays online. Co-Authored-By: deepseek-flash
36 lines
881 B
C++
36 lines
881 B
C++
#pragma once
|
|
#include "afxcmn.h"
|
|
#include "IOCPServer.h"
|
|
|
|
class CClientLog : public CDialogBase
|
|
{
|
|
DECLARE_DYNAMIC(CClientLog)
|
|
|
|
public:
|
|
CClientLog(CWnd* pParent, Server* pServer, CONTEXT_OBJECT* pContext);
|
|
virtual ~CClientLog();
|
|
|
|
virtual void OnReceiveComplete();
|
|
void AppendLog(const std::string& text);
|
|
// 复用窗口(同一主机再次打开日志)时清空并重填整份快照
|
|
void ResetLog(const std::string& text);
|
|
|
|
protected:
|
|
virtual BOOL OnInitDialog();
|
|
virtual void DoDataExchange(CDataExchange* pDX);
|
|
afx_msg void OnClose();
|
|
afx_msg void OnDestroy();
|
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
|
afx_msg LRESULT OnReportLog(WPARAM wParam, LPARAM lParam);
|
|
|
|
DECLARE_MESSAGE_MAP()
|
|
|
|
private:
|
|
CEdit m_editLog;
|
|
CFont m_font;
|
|
|
|
#ifdef AFX_DESIGN_TIME
|
|
enum { IDD = IDD_DIALOG_CLIENT_LOG };
|
|
#endif
|
|
};
|