📄 pci16prdlg.cpp
字号:
// pci16prDlg.cpp : implementation file
//
#include "stdafx.h"
#include "pci16pr.h"
#include "pci16prDlg.h"
#include "mystatic.h"
#include "pci16pr1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPci16prDlg dialog
CPci16prDlg::CPci16prDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPci16prDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPci16prDlg)
// 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 CPci16prDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPci16prDlg)
DDX_Control(pDX, IDC_INPUT, m_input);
DDX_Control(pDX, IDC_OUTPUT,m_output);
DDX_Control(pDX, IDC_PCI16PRCTRL1, m_pci16pr);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPci16prDlg, CDialog)
//{{AFX_MSG_MAP(CPci16prDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_LBUTTONDOWN()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPci16prDlg message handlers
BOOL CPci16prDlg::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
// TODO: Add extra initialization here
m_output.EnableLeftBD(true);
m_input.SetBitCount(16);
m_input.SetLampSize(18,5);
m_output.SetBitCount(16);
m_output.SetLampSize(18,5);
SetTimer(50,NULL,NULL);
return m_pci16pr.Init(0); // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CPci16prDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPci16prDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CPci16prDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
m_output.GetWindowRect(rect);
ClientToScreen(&point);
if (rect.PtInRect(point)){
point.x-=rect.left;
point.y-=rect.top;
m_output.OnLButtonDown(0,point);
int oudata=m_output.GetFlagVal();
m_pci16pr.DataOut(oudata);
UpdateData(FALSE);
}
CDialog::OnLButtonDown(nFlags, point);
}
void CPci16prDlg::OnButton1()
{
// TODO: Add your control notification handler code here
unsigned short rb=m_pci16pr.ReadBack();
char rbstr[17];
for(int i=0;i<16;i++)
{
if(rb%2)
rbstr[i]=0x31;
else
rbstr[i]=0x30;
rb/=2;
}
rbstr[16]=0;
GetDlgItem(IDC_EDIT1)->SetWindowText(rbstr);
}
void CPci16prDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
short inflag=m_pci16pr.DataIn();
m_input.SetFlagVal(inflag);
m_input.Invalidate();
CDialog::OnTimer(nIDEvent);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -