資源簡介
C++實現QQ的聊天功能,實現了一對一聊天,群聊。實現文件的收發,以及把實現程序托盤隱藏。
代碼片段和文件信息
//?ChatMoreDlg.cpp?:?implementation?file
//
#include?“stdafx.h“
#include?“miniqq.h“
#include?“ChatMoreDlg.h“
#include?“MiniQQDlg.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CChatMoreDlg?dialog
CChatMoreDlg::CChatMoreDlg(CWnd*?pParent?/*=NULL*/)
:?CDialog(CChatMoreDlg::IDD?pParent)
{
//{{AFX_DATA_INIT(CChatMoreDlg)
//}}AFX_DATA_INIT
m_hIcon?=?AfxGetApp()->LoadIcon(IDR_MAINframe);
m_pSocketChat?=?NULL;
//設置?192.168.0.100?(張三)?23:23:23?的顏色?為天藍色
ZeroMemory(&m_cfBlue?sizeof(CHARFORMAT));
m_cfBlue.cbSize?=?sizeof(CHARFORMAT);
m_cfBlue.dwMask?=?CFM_BOLD?|?CFM_COLOR?|?CFM_FACE?|?CFM_ITALIC?|?CFM_SIZE?|?CFM_UNDERLINE;
strcpy(m_cfBlue.szFaceName?_T(“宋體“));//設置字體 System
m_cfBlue.crTextColor?=?RGB(0?128?255);?//文字顏色
m_cfBlue.dwEffects?=?0;
// m_cfBlue.yHeight?=?12?*?12?*?2;//文字高度
//設置?聊天內容?的顏色?為黑色
ZeroMemory(&m_cfBlack?sizeof(CHARFORMAT));
m_cfBlack.cbSize?=?sizeof(CHARFORMAT);
m_cfBlack.dwMask?=?CFM_BOLD?|?CFM_COLOR?|?CFM_FACE?|?CFM_ITALIC?|?CFM_SIZE?|?CFM_UNDERLINE;
strcpy(m_cfBlack.szFaceName?_T(“宋體“));//設置字體
m_cfBlack.crTextColor?=?RGB(0?0?0);?//文字顏色
????m_cfBlack.dwEffects?=?0;
//????m_cfBlack.yHeight?=?12*12?*?3;//文字高度
}
void?CChatMoreDlg::DoDataExchange(CDataExchange*?pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChatMoreDlg)
DDX_Control(pDX?IDC_RICHEDIT?m_richedit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChatMoreDlg?CDialog)
//{{AFX_MSG_MAP(CChatMoreDlg)
ON_BN_CLICKED(ID_BTN_SEND?OnBtnSend)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CChatMoreDlg?message?handlers
void?CChatMoreDlg::OnCancel()?
{
this->ShowWindow(SW_HIDE);
//CDialog::OnCancel();
}
void?CChatMoreDlg::OnClose()?
{
//?TODO:?Add?your?message?handler?code?here?and/or?call?default
this->ShowWindow(SW_HIDE);
// CDialog::OnClose();
}
BOOL?CChatMoreDlg::OnInitDialog()?
{
CDialog::OnInitDialog();
//?Set?the?icon?for?this?dialog.??The?framework?does?this?automatically
//??when?the?application‘s?main?window?is?not?a?dialog
SetIcon(m_hIcon?TRUE); //?Set?big?icon
SetIcon(m_hIcon?FALSE); //?Set?small?icon
//?TODO:?Add?extra?initialization?here
m_pSocketChat?=?&(((CMiniQQDlg?*)AfxGetMainWnd())->m_socketChat);
return?FALSE;??//?return?TRUE?unless?you?set?the?focus?to?a?control
??????????????//?EXCEPTION:?OCX?Property?Pages?should?return?FALSE
}
void?CChatMoreDlg::OnBtnSend()?
{
//1.?獲取?用戶輸入的內容sSend
//待處理:當用戶輸入超過RecvProcChat中定義的1024字節時,需要分段處理
CString?sSend;
GetDlgItemText(IDC_EDIT_MSG?sSend);
SetDlgItemText(IDC_EDIT_MSG?““);
GetDlgItem(IDC_EDIT_MSG)->SetFocus();
if?(sSend.IsEmpty())?return;
//2.?SendTo()向m_pUserInfo->sIP的6001端口發送數據sSend
CHATMSG?sendBuf?=?{CHAT_MORE?0};
strcpy
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-08-13?16:04??MiniQQ_Only_UDP\
?????文件????????4774??2017-04-14?10:24??MiniQQ_Only_UDP\ChatMoreDlg.cpp
?????文件????????1540??2017-04-14?10:24??MiniQQ_Only_UDP\ChatMoreDlg.h
?????文件???????21278??2017-04-14?10:24??MiniQQ_Only_UDP\ChatOneDlg.cpp
?????文件????????2550??2017-04-14?10:24??MiniQQ_Only_UDP\ChatOneDlg.h
?????文件????????2673??2017-04-14?10:24??MiniQQ_Only_UDP\Common.cpp
?????文件?????????690??2017-04-14?10:24??MiniQQ_Only_UDP\Common.h
?????目錄???????????0??2018-08-13?16:04??MiniQQ_Only_UDP\Debug\
?????文件???????31468??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\CL.read.1.tlog
?????文件????????5072??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\CL.write.1.tlog
?????文件???????40764??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\ChatMoreDlg.obj
?????文件???????13429??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\ChatMoreDlg.sbr
?????文件???????11372??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\ChatOneDlg.sbr
?????文件???????21872??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\Common.obj
?????文件????????2865??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\Common.sbr
?????文件??????????61??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\MiniQQ.lastbuildstate
?????文件????????9726??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\MiniQQ.log
?????文件???????31022??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\MiniQQ.obj
?????文件????24641536??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\MiniQQ.pch
?????文件???????10028??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\MiniQQ.sbr
?????文件???????????0??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\MiniQQ.unsuccessfulbuild
?????文件???????????0??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\MiniQQ.write.1.tlog
?????文件??????127129??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\MiniQQDlg.obj
?????文件???????31373??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\MiniQQDlg.sbr
?????文件???????16044??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\MyAsyncSocket.obj
?????文件????????8004??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\MyAsyncSocket.sbr
?????文件???????27860??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\NicknameDlg.obj
?????文件????????3467??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\NicknameDlg.sbr
?????文件???????17366??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\RecvFile.obj
?????文件???????11393??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\RecvFile.sbr
?????文件???????17024??2017-11-22?17:17??MiniQQ_Only_UDP\Debug\SendFile.obj
............此處省略40個文件信息
評論
共有 條評論