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

📄 sendmessagedlg.cpp

📁 c++系统开发实例精粹内附的80例源代码 环境:windows2000,c++6.0
💻 CPP
字号:
//////////////////////////////////////////////////////////////////////
// FileFury
// Copyright (c) 2000 Tenebril Incorporated
// All rights reserved.
//
// This source code is governed by the Tenebril open source
// license (http://www.tenebril.com/developers/opensource/license.html)
//
// For more information on this and other open source applications,
// visit the Tenebril OpenSource page:
//       http://www.tenebril.com/developers/opensource
//
//////////////////////////////////////////////////////////////////////

// CSendMessageDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Oscar.h"
#include "SendMessageDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSendMessageDlg dialog


CSendMessageDlg::CSendMessageDlg(CWnd* pParent, LPCTSTR czPreDest, LPCTSTR czPreName)
	: CDialog(CSendMessageDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSendMessageDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

	m_bIsOK = FALSE;
	m_cszPreDest = czPreDest;
	m_cszPreName = czPreName;
}


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


BEGIN_MESSAGE_MAP(CSendMessageDlg, CDialog)
	//{{AFX_MSG_MAP(CSendMessageDlg)
	ON_EN_CHANGE(IDC_DEST, OnChangeDest)
	ON_EN_CHANGE(IDC_MESSAGE, OnChangeMessage)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSendMessageDlg message handlers

void CSendMessageDlg::OnChangeDest() 
{
	// Update the OK button.
	UpdateOKButton();
}

void CSendMessageDlg::OnChangeMessage() 
{
	// Update the OK button.
	UpdateOKButton();	
}

void CSendMessageDlg::OnOK() 
{
	// Get the message and destination text.
	GetDlgItemText(IDC_DEST, m_cszDestination);
	GetDlgItemText(IDC_MESSAGE, m_cszMessage);
	m_bIsOK = TRUE;
	
	CDialog::OnOK();
}

CString CSendMessageDlg::GetMessage()
{
	if(m_bIsOK)
		return m_cszMessage;

	return _T("");
}

CString CSendMessageDlg::GetDestination()
{
	if(m_bIsOK)
		return m_cszDestination;

	return _T("");
}

void CSendMessageDlg::UpdateOKButton()
{
	CString cszDest;
	CString cszMessage;

	GetDlgItemText(IDC_DEST, cszDest);
	GetDlgItemText(IDC_MESSAGE, cszMessage);

	// Get the OK button.
	CWnd *pOK = GetDlgItem(IDOK);
	ASSERT(pOK);

	// Enable the OK button iff both strings are non-empty.
	if(cszDest.GetLength() > 0 &&
		cszMessage.GetLength() > 0)
		pOK->EnableWindow(TRUE);
	else
		pOK->EnableWindow(FALSE);

	return;
}

BOOL CSendMessageDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// Check to see if we're supposed to set the destination information.
	if(m_cszPreDest.GetLength() > 0)
	{
		// Set the destination.
		SetDlgItemText(IDC_DEST, m_cszPreDest);

		// Disallow changing the destination.
		CWnd *pWnd = GetDlgItem(IDC_DEST);
		ASSERT(pWnd);
		pWnd->EnableWindow(FALSE);
	}
	if(m_cszPreName.GetLength() > 0)
	{
		// Set the name.
		SetDlgItemText(IDC_DESTNAME, _T("Name: ") + m_cszPreName);
	}

	// Update the OK button.
	UpdateOKButton();

	// Set the icon.
	CStatic *pGuider;
	CRect crGuider;

	pGuider = (CStatic *)GetDlgItem(IDC_LOGOGUIDER);
	pGuider->GetWindowRect(&crGuider);
	ScreenToClient(&crGuider);

	m_cLogoBox.Create(WS_VISIBLE | WS_CHILD | WS_DISABLED,
		crGuider, this, IDC_LOGOBOX, IDB_CHATICON,
		CSize(52, 40), RGB(191, 191, 191));
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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