www.pudn.com > MyQQClient.zip > ChatAction.cpp


// ChatAction.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "MyQQClient.h" 
#include "ChatAction.h" 
#include "ChatDialog.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CChatAction dialog 
 
 
CChatAction::CChatAction(CWnd* pParent /*=NULL*/) 
	: CDialog(CChatAction::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CChatAction) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
 
void CChatAction::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CChatAction) 
	DDX_Control(pDX, IDOK, m_OK); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CChatAction, CDialog) 
	//{{AFX_MSG_MAP(CChatAction) 
	ON_WM_TIMER() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CChatAction message handlers 
 
void CChatAction::OnTimer(UINT nIDEvent)  
{ 
	m_Rect.top -=5; 
	m_Rect.bottom -=5; 
	MoveWindow(&m_Rect); 
	if(m_Rect.top < m_Height - 150) 
		KillTimer(1); 
	 
	CDialog::OnTimer(nIDEvent); 
} 
 
BOOL CChatAction::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
 
	BOOL flag;			//得到屏幕的分辨率 
	LPDEVMODE gpCurrentMode; 
	gpCurrentMode=new DEVMODE; 
	flag=EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,gpCurrentMode); 
	gpCurrentMode->dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT|DM_DISPLAYFLAGS|DM_DISPLAYFREQUENCY; 
	 
	int width=gpCurrentMode->dmPelsWidth; 
    int height=gpCurrentMode->dmPelsHeight; 
 
	CRect rect; 
	this->GetWindowRect(&rect); 
	CRect rectMov; 
	rectMov.left = width - rect.Width(); 
	rectMov.top = height; 
	rectMov.right = width; 
	rectMov.bottom = height + rect.Height(); 
	m_Rect = rectMov; 
	m_Height = height; 
 
	m_OK.SetWindowText(m_strName + "有话说"); 
	this->MoveWindow(rectMov); 
	SetTimer(1,80,NULL); 
	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void CChatAction::OnOK()  
{ 
	CChatDialog * ChatDialog; 
	ChatDialog = new CChatDialog(); 
	ChatDialog->Create(IDD_DIALOG_CHAT); 
	ChatDialog->m_UserName = m_strClientName; 
	ChatDialog->m_ClientName = m_strName; 
	ChatDialog->m_pClientSocket = m_pMainSocket; 
	m_pMainSocket->m_ChatDlgs.Add(ChatDialog); 
	ChatDialog->ShowWindow(SW_SHOW); 
	ChatDialog->DisplayMessage(m_strName,m_strConnect); 
 
	CDialog::OnOK(); 
}