📄 codedlg.cpp
字号:
// CodeDlg.cpp : implementation file
//
#include "stdafx.h"
#include "yuntai.h"
#include "CodeDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCodeDlg dialog
int atoibase2(const char * string)
{
int nRet=0;
const char* temp=string;
int len=strlen(string);
while((*temp)!=0)
{
nRet+=(((*temp)-48)<<(len-1-(temp-string)));
temp+=1;
}
return nRet;
}
CCodeDlg::CCodeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCodeDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCodeDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CCodeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCodeDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCodeDlg, CDialog)
//{{AFX_MSG_MAP(CCodeDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCodeDlg message handlers
BOOL CCodeDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
for(int i=0; i<32; i++)
{
m_ctrlChoose[i].SubclassDlgItem(IDC_CODE1+i,this);
m_ctrlChoose[i].SetLimitText(8);
CString str;
itoa(m_byCodeChoose[i],str.GetBuffer(100),2);
str.ReleaseBuffer();
char temp[9];
while(str.GetLength()<8)
str.Insert(0,'0');
memcpy(temp,str.Right(8),8);
temp[9]=0;
m_ctrlChoose[i].SetSel(0,-1);
m_ctrlChoose[i].ReplaceSel(temp);
}
for(i=0; i<5; i++)
{
m_ctrlAct[i].SubclassDlgItem(IDC_CODE_UP+i,this);
m_ctrlAct[i].SetLimitText(8);
CString str;
itoa(m_byCodeAct[i],str.GetBuffer(100),2);
str.ReleaseBuffer();
char temp[9];
while(str.GetLength()<8)
str.Insert(0,'0');
memcpy(temp,str.Right(8),8);
temp[9]=0;
m_ctrlAct[i].SetSel(0,-1);
m_ctrlAct[i].ReplaceSel(temp);
}
for(i=0; i<6; i++)
{
m_ctrlMir[i].SubclassDlgItem(IDC_CODE_FOCUS1+i,this);
m_ctrlMir[i].SetLimitText(8);
CString str;
itoa(m_byCodeMir[i],str.GetBuffer(100),2);
str.ReleaseBuffer();
char temp[9];
while(str.GetLength()<8)
str.Insert(0,'0');
memcpy(temp,str.Right(8),8);
temp[9]=0;
m_ctrlMir[i].SetSel(0,-1);
m_ctrlMir[i].ReplaceSel(temp);
}
for(i=0; i<3; i++)
{
m_ctrlStatus[i].SubclassDlgItem(IDC_CODE_LIGHT+i,this);
m_ctrlStatus[i].SetLimitText(8);
CString str;
itoa(m_byCodeStatus[i],str.GetBuffer(100),2);
str.ReleaseBuffer();
char temp[9];
while(str.GetLength()<8)
str.Insert(0,'0');
memcpy(temp,str.Right(8),8);
temp[9]=0;
m_ctrlStatus[i].SetSel(0,-1);
m_ctrlStatus[i].ReplaceSel(temp);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCodeDlg::OnOK()
{
// TODO: Add extra validation here
//to edit : write to ini file to save code settings
char code[9];
code[9]=0;
for(int i=0; i<32; i++)
{
m_ctrlChoose[i].GetLine(0,code,8);
m_byCodeChoose[i]=(BYTE)atoibase2(code);
}
for(i=0; i<5; i++)
{
m_ctrlAct[i].GetLine(0,code,8);
m_byCodeAct[i]=(BYTE)atoibase2(code);
}
for(i=0; i<6; i++)
{
m_ctrlMir[i].GetLine(0,code,8);
m_byCodeMir[i]=(BYTE)atoibase2(code);
}
for(i=0; i<3; i++)
{
m_ctrlStatus[i].GetLine(0,code,8);
m_byCodeStatus[i]=(BYTE)atoibase2(code);
}
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -