Improve: Reduce master program redundant code

This commit is contained in:
yuanyuanxiang
2025-06-28 23:52:26 +08:00
parent 44f28defa2
commit c59232d179
39 changed files with 361 additions and 872 deletions

View File

@@ -14,12 +14,8 @@
CChat::CChat(CWnd* pParent, ISocketBase* pIOCPServer, ClientContext* pContext)
: DialogBase(CChat::IDD, pParent, pIOCPServer, pContext, 0)
: DialogBase(CChat::IDD, pParent, pIOCPServer, pContext, IDI_CHAT)
{
m_hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_CHAT));
m_iocpServer = pIOCPServer;
m_pContext = pContext;
m_bOnClose = FALSE;
}
@@ -51,13 +47,13 @@ BOOL CChat::OnInitDialog()
CDialog::OnInitDialog();
CString str;
str.Format(_T("Զ<EFBFBD>̽<EFBFBD≯ - %s"), m_pContext->PeerName.c_str()),
str.Format(_T("Զ<EFBFBD>̽<EFBFBD≯ - %s"), m_ContextObject->PeerName.c_str()),
SetWindowText(str);
m_editTip.SetWindowText(_T("<EFBFBD><EFBFBD>ʾ: <20>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>Żᵯ<C5BB><E1B5AF>"));
m_editNewMsg.SetLimitText(4079);
// TODO: Add extra initialization here
BYTE bToken = COMMAND_NEXT_CHAT;
m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE));
m_iocpServer->Send(m_ContextObject, &bToken, sizeof(BYTE));
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
@@ -71,8 +67,8 @@ void CChat::OnReceive()
void CChat::OnReceiveComplete()
{
m_pContext->m_DeCompressionBuffer.Write((LPBYTE)_T(""), 1);
char* strResult = (char*)m_pContext->m_DeCompressionBuffer.GetBuffer(0);
m_ContextObject->m_DeCompressionBuffer.Write((LPBYTE)_T(""), 1);
char* strResult = (char*)m_ContextObject->m_DeCompressionBuffer.GetBuffer(0);
SYSTEMTIME st;
GetLocalTime(&st);
char Text[5120] = { 0 };
@@ -93,7 +89,7 @@ void CChat::OnButtonSend()
return; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϢΪ<CFA2>ղ<EFBFBD><D5B2><EFBFBD><EFBFBD><EFBFBD>
}
m_editTip.ShowWindow(SW_HIDE);
m_iocpServer->Send(m_pContext, (LPBYTE)str, lstrlen(str) + sizeof(char));
m_iocpServer->Send(m_ContextObject, (LPBYTE)str, lstrlen(str) + sizeof(char));
SYSTEMTIME st;
GetLocalTime(&st);
char Text[5120] = { 0 };
@@ -114,7 +110,7 @@ void CChat::OnButtonEnd()
void CChat::OnClose()
{
m_ContextObject->CancelIO();
CancelIO();
CDialogBase::OnClose();
}
@@ -140,7 +136,7 @@ HBRUSH CChat::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
void CChat::PostNcDestroy()
{
if (!m_bOnClose)
if (!m_bIsClosed)
OnCancel();
CDialog::PostNcDestroy();
delete this;
@@ -170,11 +166,11 @@ void CChat::OnBnClickedButton_LOCK()
{
BYTE bToken = COMMAND_CHAT_SCREEN_LOCK;
m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE));
m_iocpServer->Send(m_ContextObject, &bToken, sizeof(BYTE));
}
void CChat::OnBnClickedButton_UNLOCK()
{
BYTE bToken = COMMAND_CHAT_SCREEN_UNLOCK;
m_iocpServer->Send(m_pContext, &bToken, sizeof(BYTE));
m_iocpServer->Send(m_ContextObject, &bToken, sizeof(BYTE));
}