privatemsgdlg.cpp

来自「一个简易的聊天室程序」· C++ 代码 · 共 89 行

CPP
89
字号
// PrivateMsgDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ChatClient.h"
#include "PrivateMsgDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPrivateMsgDlg dialog


CPrivateMsgDlg::CPrivateMsgDlg(CWnd* pParent /*=NULL*/, BOOL bDisplayOnly , CString strMsg)
	: CDialog(CPrivateMsgDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPrivateMsgDlg)
	m_PrivateMsg = strMsg; //_T("");
	m_PrivateMsgRE = strMsg; //_T("");
	//}}AFX_DATA_INIT
	m_pParent = pParent;
	m_nID = CPrivateMsgDlg::IDD;
	m_bDisplayOnly = bDisplayOnly;
}

void CPrivateMsgDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPrivateMsgDlg)
//	DDX_Text(pDX, IDC_EDIT_PRIVATE_MSG, m_PrivateMsg);
//	DDV_MaxChars(pDX, m_PrivateMsg, 200);
	DDX_Text(pDX, IDC_RICHEDIT_PRIVATE_MSG, m_PrivateMsgRE);
	DDV_MaxChars(pDX, m_PrivateMsgRE, 200);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPrivateMsgDlg, CDialog)
	//{{AFX_MSG_MAP(CPrivateMsgDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPrivateMsgDlg message handlers

BOOL CPrivateMsgDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	AfxInitRichEdit();
	
	if(m_bDisplayOnly)
	{
		GetDlgItem(IDOK)->EnableWindow(FALSE);
		CRichEditCtrl* editctrl = (CRichEditCtrl*)GetDlgItem(IDC_RICHEDIT_PRIVATE_MSG);
		editctrl->SetReadOnly(TRUE);
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPrivateMsgDlg::OnOK() 
{
	UpdateData();

	if (m_PrivateMsgRE.IsEmpty())
		return;
	
	CDialog::OnOK();
}

BOOL CPrivateMsgDlg::Create() //LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
{
	return CDialog::Create(m_nID, m_pParent); //IDD, pParentWnd);
}

int CPrivateMsgDlg::DoModal() 
{
	AfxInitRichEdit();
	
	return CDialog::DoModal();
}

⌨️ 快捷键说明

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