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

📄 messagedisplay.cpp

📁 一个简单的日程计划工具。用VC7+DAO35开发。有兴趣的话下载后自己研究吧。
💻 CPP
字号:
// MessageDisplay.cpp : implementation file
//

#include "stdafx.h"
#include "Alarm.h"
#include "MessageDisplay.h"
#include "math.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMessageDisplay dialog


CMessageDisplay::CMessageDisplay(CWnd* pParent /*=NULL*/)
	: CDialog(CMessageDisplay::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMessageDisplay)
	//}}AFX_DATA_INIT
}


void CMessageDisplay::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMessageDisplay)
	DDX_Control(pDX, IDC_STATIC_MESSAGE, m_ctlMessage);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMessageDisplay, CDialog)
	//{{AFX_MSG_MAP(CMessageDisplay)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMessageDisplay message handlers

void CMessageDisplay::OnPaint() 
{
	// TODO: Add your message handler code here
	if(!IsIconic())
	{
		CDialog::OnPaint();
		CRect rect;
		CWnd* m_pWnd;
		m_pWnd = GetDlgItem(IDC_STATIC_MESSAGE);
		m_pWnd->GetClientRect(rect);

		CClientDC pDC(m_pWnd);
		DisplayMessage(pDC.m_hDC,rect.Width(),rect.Height());
	}
}

void CMessageDisplay::DisplayMessage(HDC hDC, unsigned int cx, unsigned int cy)
{
	CPen DrawPen;
	DrawPen.CreatePen(PS_SOLID,2,RGB(0,255,0));
	CBrush MyBrush;
	CRect rect(0,0,cx,cy);
	MyBrush.CreateSolidBrush(RGB(0,0,0));
	HBRUSH OldBrush = (HBRUSH)SelectObject(hDC,MyBrush);
	HPEN OldPen = (HPEN)SelectObject(hDC,DrawPen);
	FillRect(hDC,rect,OldBrush);
	
	SetBkMode(hDC,TRANSPARENT);
	Rectangle(hDC,1,1,rect.Width(),rect.Height());

	SetTextColor(hDC,RGB(0,255,0));
	TextOut(hDC,7,12,m_strDateTime,m_strDateTime.GetLength());
	
	CFont font;
	int nLength = m_strPlan.GetLength();
	int nFontSize = cy / nLength * 64;
	if(nFontSize >= 240)
	{
		nFontSize = 240;
	}
	font.CreatePointFont(nFontSize,"宋体",NULL);
	CFont* OldFont = (CFont*)SelectObject(hDC,font);
	SetTextColor(hDC,RGB(255,255,0));
	TextOut(hDC, 7, 35, m_strPlan, nLength);
	SelectObject(hDC,OldPen);
	SelectObject(hDC,OldBrush);
	SelectObject(hDC,OldFont);
}

BOOL CMessageDisplay::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CRect rect;
	GetWindowRect(rect);
	int nScreenCX = ::GetSystemMetrics(SM_CXSCREEN);
	int nScreenCY = ::GetSystemMetrics(SM_CYSCREEN);
	int nPosX = (nScreenCX / 2) - (rect.Width() / 2);
	int nPosY = (nScreenCY / 2) - (rect.Height() / 2);
	SetWindowText(m_strPlan);
	SetWindowPos(&wndTop ,nPosX,nPosY,rect.Width(),rect.Height(),SWP_SHOWWINDOW );
	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 + -