【VC开源代码栏目提醒】:本文主要为网学会员提供NetMsgClientDlg.cpp,希望对需要NetMsgClientDlg.cpp网友有所帮助,学习一下!
// NetMsgClientDlg.cpp : implementation file
//
#include "stdafx.h"
#include "NetMsgClient.h"
#include "NetMsgClientDlg.h"
#include "ConnectPrompt.h"
#include "LoginDlg.h"
#include "ChatDlg.h"
#include "UpdateUserInfoDlg.h"
#include "TRAYICON.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
CConnectPrompt connectPromptDlg;
CLoginDlg m_loginDlg;
CChatDlg *m_pChatDlg[MAX_CHAT_NUM];//包括主动和被动形式
CUpdateUserInfoDlg m_updateUserInfoDlg;
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNetMsgClientDlg dialog
CNetMsgClientDlg::CNetMsgClientDlg(CWnd* pParent /*=NULL*/)
: CDialog(CNetMsgClientDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CNetMsgClientDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
// m_hIconMan = AfxGetApp()->LoadIcon(IDR_ICON_MAN);
m_nId = 0;
memset(m_strPwd,0,sizeof(m_strPwd));
}
CNetMsgClientDlg::~CNetMsgClientDlg()
{
}
void CNetMsgClientDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNetMsgClientDlg)
DDX_Control(pDX, IDC_LIST_ONLINEUSER, m_listOnlineUser);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNetMsgClientDlg, CDialog)
//{{AFX_MSG_MAP(CNetMsgClientDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_REFRESHONLINEUSER, OnRefreshonlineuser)
ON_NOTIFY(NM_DBLCLK, IDC_LIST_ONLINEUSER, OnDblclkListOnlineuser)
ON_BN_CLICKED(IDC_UPDATEINFO, OnUpdateinfo)
ON_WM_TIMER()
ON_COMMAND(ID_MENU_EXIT, OnMenuExit)
ON_COMMAND(ID_MENU_RESTORE, OnMenuRestore)
ON_WM_CLOSE()
ON_COMMAND(ID_ABOUTNETMSG, OnAboutnetmsg)
ON_MESSAGE(WM_ICON_NOTIFY, OnTrayNotification)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CNetMsgClientDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CNetMsgClientDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CNetMsgClientDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
if(nID == SC_MINIMIZE)
{
m_isDlgMaximized = TRUE;
m_trayIcon.ShowIcon();
ShowWindow(SW_HIDE); //隐藏窗口
}
}
/////////////////////////////////////////////////////////////////////////////
// CNetMsgClientDlg message handlers
BOOL CNetMsgClientDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..