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

📄 lcdsampledlg.cpp

📁 EVC实现LCD屏
💻 CPP
字号:
// LCDSampleDlg.cpp : implementation file
//

#include "stdafx.h"
#include "LCDSample.h"
#include "LCDSampleDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLCDSampleDlg dialog

CLCDSampleDlg::CLCDSampleDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CLCDSampleDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLCDSampleDlg)
	m_nBGPeriod = 5;
	m_nFloorNumber = 13;
	m_strAVIFile = _T("");
	m_nDirection = 0;
		// 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);
}

void CLCDSampleDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLCDSampleDlg)
	DDX_Control(pDX, IDC_SHOW_TIME_COLOR, m_wndShowTimeColor);
	DDX_Text(pDX, IDC_BG_PERIOD, m_nBGPeriod);
	DDV_MinMaxInt(pDX, m_nBGPeriod, 1, 1000);
	DDX_Text(pDX, IDC_FLOOR_NUMBER, m_nFloorNumber);
	DDV_MinMaxInt(pDX, m_nFloorNumber, 1, 999);
	DDX_Text(pDX, IDC_AVI_FILE, m_strAVIFile);
	DDX_Radio(pDX, IDC_DIRECTION_UP, m_nDirection);
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CLCDSampleDlg, CDialog)
	//{{AFX_MSG_MAP(CLCDSampleDlg)
	//ON_BN_CLICKED(IDC_SET_TIME_FONT, OnSetTimeFont)
	ON_BN_CLICKED(IDC_SET_TIME_COLOR, OnSetTimeColor)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CLCDSampleDlg message handlers

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

	CClientDC dc(this);


	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// 初始化时间显示字体
	CFont font;
	font.CreatePointFont(440, _T("宋体"),&dc);
	font.GetLogFont(&m_lfTimeFont);
	ShowTimeFont();

	// 初始化时间显示颜色
	m_crTimeColor = RGB(96,0,0);
	m_wndShowTimeColor.SetColor(m_crTimeColor);

	// 创建LCD显示窗口
	m_pdlgLCD = new LCDDlg(m_nBGPeriod, m_nFloorNumber, m_nDirection, m_strAVIFile, m_lfTimeFont, m_crTimeColor);
	m_pdlgLCD->Create(IDD_LCD_DLG, GetDesktopWindow());
	m_pdlgLCD->ShowWindow(SW_SHOW);

	return TRUE;  // return TRUE  unless you set the focus to a control

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	//SetIcon(m_hIcon, TRUE);			// Set big icon
	//SetIcon(m_hIcon, FALSE);		// Set small icon
	
	//CenterWindow(GetDesktopWindow());	// center to the hpc screen

	// TODO: Add extra initialization here
	
	//return TRUE;  // return TRUE  unless you set the focus to a control
}



void CLCDSampleDlg::ShowTimeFont()
{
	CWindowDC dc(CWnd::GetDesktopWindow());
	//int height = -MulDiv(m_lfTimeFont.lfHeight, 72, dc.GetDeviceCaps(LOGPIXELSY));
	int height = 120;
	CString strFont;
	strFont.Format(_T("%s; %dpt"), m_lfTimeFont.lfFaceName, height);
	GetDlgItem(IDC_SHOW_TIME_FONT)->SetWindowText(strFont);
}

/*
void CLCDSampleDlg::OnSetTimeFont() 
{
	// 设置时间显示字体
	CFontDialog dlg(&m_lfTimeFont, CF_EFFECTS | CF_SCREENFONTS);
	if (dlg.DoModal() == IDOK)
	{
		dlg.GetCurrentFont(&m_lfTimeFont);
		ShowTimeFont();
	}
}
*/

void CLCDSampleDlg::OnSetTimeColor() 
{
	// 设置时间显示颜色
	CColorDialog dlg(m_crTimeColor);
	if (dlg.DoModal() == IDOK)
	{
		m_crTimeColor = dlg.GetColor();
		m_wndShowTimeColor.SetColor(m_crTimeColor);
	}
}

void CLCDSampleDlg::OnOK() 
{
	// 获取参数
	if (!UpdateData(TRUE))
		return;

	// 设置LCD显示窗口
	m_pdlgLCD->SetParameter(m_nBGPeriod, m_nFloorNumber, m_nDirection, m_strAVIFile, m_lfTimeFont, m_crTimeColor);

	// CDialog::OnOK();
}

void CLCDSampleDlg::OnCancel() 
{
	// 删除LCD显示窗口
	m_pdlgLCD->DestroyWindow();
	delete m_pdlgLCD;

	CDialog::OnCancel();
}

⌨️ 快捷键说明

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