⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showmsgdlg.cpp

📁 一个采用C/S结构的信息发布接收管理程序
💻 CPP
字号:
// ShowMsgDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MsgClient.h"
#include "ShowMsgDlg.h"
#include "MsgClientDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CShowMsgDlg dialog


CShowMsgDlg::CShowMsgDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CShowMsgDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CShowMsgDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CShowMsgDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CShowMsgDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CShowMsgDlg, CDialog)
	//{{AFX_MSG_MAP(CShowMsgDlg)
	ON_WM_TIMER()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CShowMsgDlg message handlers

BOOL CShowMsgDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	ShowMsg();

//	SetTimer(WM_QUIT_MSG_TIMER,5*1000,0);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CShowMsgDlg::ShowMsg()
{
	CMsgClientDlg* pDlg=(CMsgClientDlg*)::AfxGetMainWnd();
	pReceiveInfo = pDlg->pReceiveInfo;


	iMsg=0;
	ShowNextMsg( iMsg );
	SetTimer(WM_SHOW_MSG_TIMER,1000,0);
}

void CShowMsgDlg::ShowNextMsg(int i)
{
	if ( iMsg>=pReceiveInfo->iCurrentMsgCount )
	{
		KillTimer(WM_SHOW_MSG_TIMER);
		CDialog::OnOK();
		return;
	}

	CString		strTime;
	CString		strMsg;
	CString		strTemp;

	strTime = pReceiveInfo->MsgList[i].ctAddTime.Format("%Y-%m-%d %H:%M:%S");
	strMsg.Format("%s",pReceiveInfo->MsgList[i].strMsg);
	strMsg=strMsg.Left(pReceiveInfo->MsgList[i].iMsgSize);
	strTemp.Format("%s\n%s",strTime,strMsg);
	SetDlgItemText(IDC_STATIC_MSG,strTemp);
	iMsg++;
}

void CShowMsgDlg::OnTimer(UINT nIDEvent) 
{
	if ( nIDEvent == WM_SHOW_MSG_TIMER )
	{
		ShowNextMsg(iMsg);
	}
	else
	{
		CDialog::OnOK();
	}
	
	CDialog::OnTimer(nIDEvent);
}

void CShowMsgDlg::OnDestroy() 
{
	CDialog::OnDestroy();
	
	KillTimer(WM_QUIT_MSG_TIMER);	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -