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

📄 sendmsgdlg.cpp

📁 网吧管理系统VC源码
💻 CPP
字号:
// SendMsgDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Server.h"
#include "SendMsgDlg.h"
#include "DaoMessage.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSendMsgDlg dialog


CSendMsgDlg::CSendMsgDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSendMsgDlg::IDD, pParent)
{
	bSelected = false;
	bCheckEnable = true;
	DaoRecord.Open();
	//{{AFX_DATA_INIT(CSendMsgDlg)
	m_strName = _T("");
	m_strSendMsg = _T("");
	//}}AFX_DATA_INIT
}


void CSendMsgDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSendMsgDlg)
	DDX_Control(pDX, IDC_ALL_CHECK, m_CtrlCheck);
	DDX_Control(pDX, IDC_EDIT_BUTTON, m_EditButton);
	DDX_Control(pDX, IDC_MESSAGE_EDIT, m_ControlMessage);
	DDX_Control(pDX, IDC_SAVEMESSAGE_BUTTON, m_SaveButton);
	DDX_Control(pDX, IDC_MESSAGE_COMBO, m_CtrlSendMsg);
	DDX_Control(pDX, IDC_NAME_STATIC, m_ControlName);
	DDX_Control(pDX, IDC_BORDER_STATIC, m_ControlStatic);
	DDX_CBString(pDX, IDC_MESSAGE_COMBO, m_strSendMsg);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSendMsgDlg, CDialog)
	//{{AFX_MSG_MAP(CSendMsgDlg)
	ON_BN_CLICKED(IDC_EDIT_BUTTON, OnEditButton)
	ON_BN_CLICKED(IDC_ALL_CHECK, OnAllCheck)
	ON_WM_CTLCOLOR()
	ON_WM_DESTROY()
	ON_BN_CLICKED(IDC_SAVEMESSAGE_BUTTON, OnSavemessageButton)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSendMsgDlg message handlers

void CSendMsgDlg::OnEditButton() 
{
	CRect rect;
	GetWindowRect(&rect);
	MoveWindow(rect.left,rect.top,rect.right-rect.left,335,true);

	ScreenToClient(&rect);
	CRect MsgEditRect;
	m_ControlMessage.GetWindowRect(&MsgEditRect);
	ScreenToClient(&MsgEditRect);
	m_ControlMessage.MoveWindow(MsgEditRect.left,rect.bottom - 10,MsgEditRect.right - MsgEditRect.left,MsgEditRect.bottom - MsgEditRect.top,true);
	m_ControlMessage.ShowWindow(true);

    CRect SaveButtonRect;
	m_SaveButton.GetWindowRect(&SaveButtonRect);
	ScreenToClient(&SaveButtonRect);
	m_SaveButton.MoveWindow(SaveButtonRect.left,rect.bottom + 115,SaveButtonRect.right - SaveButtonRect.left,SaveButtonRect.bottom - SaveButtonRect.top,true);
	m_SaveButton.ShowWindow(true);

	m_ControlStatic.GetWindowRect(&rect);
	ScreenToClient(&rect);
	m_ControlStatic.MoveWindow(rect.left,rect.top,rect.right-rect.left,300,true);
	m_EditButton.EnableWindow(false);
}

void CSendMsgDlg::OnAllCheck() 
{
	CRect rect;
	GetWindowRect(&rect);
	bSelected = !bSelected;

	if(bSelected)
	{
		m_ControlName.EnableWindow(false);
	}
	else
	{
		m_ControlName.EnableWindow(true);
	}
}

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

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	pSysMenu->ModifyMenu(SC_CLOSE,MF_BYCOMMAND | MF_GRAYED );

	m_SaveButton.ShowWindow(false);
	m_ControlMessage.ShowWindow(false);
	
	if(bCheckEnable)
		m_CtrlCheck.EnableWindow(true);
	else
		m_CtrlCheck.EnableWindow(false);

	m_ControlName.SetWindowText(this->m_strName);
	DaoRecord.MoveLast();
	int nCount = DaoRecord.GetRecordCount();

	if(nCount != 0)
		DaoRecord.MoveFirst();
	for(int i = 0; i < nCount; i++)
	{
		m_CtrlSendMsg.AddString(DaoRecord.m_Message);
		DaoRecord.MoveNext();
	}
	m_CtrlSendMsg.SetCurSel(0);

	return TRUE;  
}


HBRUSH CSendMsgDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	if(m_ControlName.m_hWnd == pWnd->m_hWnd) 
	{
		pDC->SetTextColor(RGB(250,0,238));
	}
	return hbr;
}



void CSendMsgDlg::OnDestroy() 
{
	CDialog::OnDestroy();
	DaoRecord.Close();
}



void CSendMsgDlg::OnSavemessageButton() 
{
    m_ControlMessage.ShowWindow(false);
 	m_SaveButton.ShowWindow(false);
 	CRect rect;
 	GetWindowRect(&rect);
 	MoveWindow(rect.left,rect.top,rect.right-rect.left,179,true);
 	m_ControlStatic.GetWindowRect(&rect);
 	ScreenToClient(&rect);
 	m_ControlStatic.MoveWindow(rect.left,rect.top,rect.right-rect.left,143,true); //35
 
 	UpdateData(true);
 	int nCount = m_ControlMessage.GetLineCount();
 	char str[256];
 	CString strTemp;
 	for(int i = 0; i < nCount; i++)
 	{
 		int Count = m_ControlMessage.GetLine(i, str,256);
 		str[Count] = '\0';
 		strTemp = CString(str);
 		strTemp.TrimLeft();
 		strTemp.TrimRight();
 		if(strTemp != "")
 		{
 			DaoRecord.AddNew();
 			DaoRecord.m_Message = strTemp;
 			DaoRecord.Update();
 			m_CtrlSendMsg.AddString(strTemp);
 		}
 	}
 	m_EditButton.EnableWindow(true);
 	m_ControlMessage.SetWindowText("");
}


⌨️ 快捷键说明

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