// GMReportDialog.cpp : ±¸Çö ÆÄÀÏÀÔ´Ï´Ù. // #include "stdafx.h" #include "MonitoringTool.h" #include "GMReportDialog.h" #include #include #include #include #include // CGMReportDialog ´ëÈ­ »óÀÚÀÔ´Ï´Ù. IMPLEMENT_DYNAMIC(CGMReportDialog, CDialog) CGMReportDialog::CGMReportDialog(CWnd* pParent /*=NULL*/) : CDialog(CGMReportDialog::IDD, pParent) { theApp.RegisterWindow(IDD_GMREPORTDIALOG, static_cast(this)); } CGMReportDialog::~CGMReportDialog() { theApp.RemoveWindow(IDD_GMREPORTDIALOG); } void CGMReportDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_REPORTLIST, m_ReportList); } BEGIN_MESSAGE_MAP(CGMReportDialog, CDialog) ON_WM_SIZE() ON_BN_CLICKED(IDC_SAVEBUTTON, OnBnClickedSavebutton) ON_BN_CLICKED(IDC_SAVEBUTTON3, OnBnClickedSavebutton3) END_MESSAGE_MAP() // CGMReportDialog ¸Þ½ÃÁö 󸮱âÀÔ´Ï´Ù. BOOL CGMReportDialog::OnInitDialog() { CDialog::OnInitDialog(); return TRUE; } void CGMReportDialog::OnOK() { ShowWindow(SW_HIDE); } void CGMReportDialog::OnCancel() { ShowWindow(SW_HIDE); } void CGMReportDialog::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); // TODO: ¿©±â¿¡ ¸Þ½ÃÁö 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù. if(m_ReportList.GetSafeHwnd()) { CRect rt; GetClientRect(rt); rt.top += 22; m_ReportList.MoveWindow(rt); } } void CGMReportDialog::AddMessage(ChatToolPkt::ChatDataSend* lpChatData) { const int MAX_CHAT_LEN = 1024; char strRecvMsg[UCHAR_MAX * 2]; memcpy(strRecvMsg, reinterpret_cast(lpChatData + 1), lpChatData->m_cChatMsgLen); strRecvMsg[lpChatData->m_cChatMsgLen] = 0; char strChatMsg[MAX_CHAT_LEN]; SERVER_ID serverID; serverID.dwID = lpChatData->m_dwServerID; time_t tCurrent = time(NULL); struct tm tmCurrent = *localtime(&tCurrent); CXListBox::Color cBackColor = CXListBox::BackColor; CXListBox::Color cMessageColor = CXListBox::GMReport; _snprintf(strChatMsg, MAX_CHAT_LEN - 1, "%s\t [Z:%02d/C:%d/L:%04x][%02d:%02d] %s : %s", theApp.GetServerName((unsigned int)serverID.GetGroup()), serverID.GetZone(), serverID.GetChannel(), lpChatData->m_usLang, tmCurrent.tm_hour, tmCurrent.tm_min, lpChatData->m_szSenderName, strRecvMsg); m_ReportList.AddLine(cMessageColor, cBackColor, strChatMsg, true); ShowWindow(SW_SHOW); } void CGMReportDialog::OnBnClickedSavebutton() { // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù. CString strFilter = _T("Text File (*.txt)|*.txt||"); CFileDialog dlg(FALSE, _T("txt"), _T(""), OFN_HIDEREADONLY|OFN_READONLY, strFilter, this); if (dlg.DoModal() == IDOK) { CFile file(dlg.GetPathName(), CFile::modeWrite|CFile::modeCreate); CString str; CString line = _T("\r\n"); int iCount = m_ReportList.GetCount(); for(int i = 0; i < iCount; ++i) { m_ReportList.GetText(i, str); file.Write(str.GetString(), str.GetLength()); file.Write(line.GetString(), line.GetLength()); } } } void CGMReportDialog::OnBnClickedSavebutton3() { // TODO: ¿©±â¿¡ ÄÁÆ®·Ñ ¾Ë¸² 󸮱â Äڵ带 Ãß°¡ÇÕ´Ï´Ù. m_ReportList.ResetContent(); }