📄 interruptappdlg.cpp
字号:
// InterruptAppDlg.cpp : implementation file
//
#include "stdafx.h"
#include "InterruptApp.h"
#include "InterruptAppDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInterruptAppDlg dialog
CInterruptAppDlg::CInterruptAppDlg(CWnd* pParent /*=NULL*/)
: CDialog(CInterruptAppDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CInterruptAppDlg)
m_time = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
number = 0;
m_Masterbrush = CreateSolidBrush(RGB(192,220,200));
}
void CInterruptAppDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInterruptAppDlg)
DDX_Control(pDX, IDC_INT_BTN_EXIT, m_exit);
DDX_Control(pDX, IDC_INT_BTN_RESET, m_reset);
DDX_Text(pDX, IDC_INT_TIME, m_time);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInterruptAppDlg, CDialog)
//{{AFX_MSG_MAP(CInterruptAppDlg)
ON_BN_CLICKED(IDC_INT_BTN_RESET, OnIntBtnReset)
ON_BN_CLICKED(IDC_INT_BTN_EXIT, OnIntBtnExit)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInterruptAppDlg message handlers
BOOL CInterruptAppDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
HWND lpClassName;
lpClassName = ::FindWindow(TEXT("HHTaskBar"), NULL);
::ShowWindow(lpClassName, SW_HIDE);
InitButton();
InitFont();
inter.OpenPort();
inter.SetWindowFun(this,OnIOread);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CInterruptAppDlg::OnIOread(CWnd *pWnd, WORD *p)
{
CInterruptAppDlg *pDlg= (CInterruptAppDlg *)pWnd;
pDlg->number = (*p);
pDlg->m_time.Format(_T("%d"),pDlg->number);
pDlg->UpdateData(false);
}
void CInterruptAppDlg::OnIntBtnReset()
{
// TODO: Add your control notification handler code here
DWORD bytes;
number = 0;
m_time = _T("0");
WriteFile(inter. m_hDev, &number, 2, &bytes, NULL);
UpdateData(false);
}
void CInterruptAppDlg::OnIntBtnExit()
{
// TODO: Add your control notification handler code here
DWORD bytes;
number = 0;
WriteFile(inter. m_hDev, &number, 2, &bytes, NULL);
inter.ClosePort();
HWND lpClassName;
lpClassName = ::FindWindow(TEXT("HHTaskBar"), NULL);
::ShowWindow(lpClassName, SW_SHOW);
OnOK();
}
void CInterruptAppDlg::InitButton()
{
m_exit.SetBkMode (false);
m_exit.SetBKColor(RGB(192,192,192),false);
m_exit.SetStyle ();
m_reset.SetBkMode (false);
m_reset.SetBKColor(RGB(192,192,192),false);
m_reset.SetStyle ();
}
void CInterruptAppDlg::InitFont()
{
CStatic* pSt = NULL;
if(m_nTitleFont.CreateFont(
30, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_BOLD, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("Arial"))) // lpszFacename
{
pSt = (CStatic*)GetDlgItem(IDC_INT_TITLE);
if(pSt!=NULL) pSt->SetFont(&m_nTitleFont);
pSt = (CStatic*)GetDlgItem(IDC_INT_CSTIME);
if(pSt!=NULL) pSt->SetFont(&m_nTitleFont);
}
if(m_nViceTitleFont.CreateFont(
35, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
_T("华文彩云"))) // lpszFacename
{
pSt = (CStatic*)GetDlgItem(IDC_INT_TIME);
if(pSt!=NULL) pSt->SetFont(&m_nViceTitleFont);
}
}
HBRUSH CInterruptAppDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(pWnd->GetDlgCtrlID()==IDC_INT_TIME)
{
pDC->SetTextColor(RGB(255,0,0));
pDC->SetBkMode(TRANSPARENT);
}
pDC->SetBkMode(TRANSPARENT);
return m_Masterbrush;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -