📄 regisaintexedlg.cpp
字号:
// RegIsaIntExeDlg.cpp : implementation file
//
#include "stdafx.h"
#include "RegIsaIntExe.h"
#include "RegIsaIntExeDlg.h"
#include "InstallSys.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define WM_EVENT_COME WM_USER+102
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
BOOL bListen=TRUE;
ULONG ulIntTimes;
CInstallSys isa_int;
UINT ThreadListen(LPVOID pParam)
{
/*CStdioFile int_record;
CFileException fileException;
if (!int_record.Open("int_record.txt", CFile::modeCreate|CFile::modeReadWrite), &fileException )
{
TRACE( "Can't open file: int_record.txt, error = %u\n",
fileException.m_cause );
}*/
DWORD wait_state;
while(bListen)
{
wait_state=WaitForSingleObject(isa_int.InterruptEvent,5000);
if(wait_state==WAIT_OBJECT_0)
{
ulIntTimes++;
SendMessage((HWND)pParam,WM_EVENT_COME,ulIntTimes,0);
/*int_record.SeekToEnd();
CString str_data;
str_data.Format("%u\n",ulIntTimes);
int_record.WriteString(str_data);*/
}
}
/*int_record.Close();*/
return TRUE;
}
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRegIsaIntExeDlg dialog
CRegIsaIntExeDlg::CRegIsaIntExeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CRegIsaIntExeDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CRegIsaIntExeDlg)
m_dIntTimes = 0;
m_dIntName = _T("System timer");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CRegIsaIntExeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRegIsaIntExeDlg)
DDX_Control(pDX, IDC_IRQ_NUM_COMBO, m_dIrqNum);
DDX_Control(pDX, IDC_TRIG_MANNER, m_dTrigManner);
DDX_Text(pDX, IDC_INT_TIMES, m_dIntTimes);
DDX_Text(pDX, IDC_INT_NAME, m_dIntName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRegIsaIntExeDlg, CDialog)
//{{AFX_MSG_MAP(CRegIsaIntExeDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_CONNECT_INT, OnConnectInt)
ON_BN_CLICKED(IDC_DISCONNECT_INT, OnDisconnectInt)
ON_MESSAGE(WM_EVENT_COME,OnEventCome)
ON_CBN_SELCHANGE(IDC_IRQ_NUM_COMBO, OnSelchangeIrqNumCombo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRegIsaIntExeDlg message handlers
BOOL CRegIsaIntExeDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 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_dIrqNum.SelectString(-1,"0");;
m_dTrigManner.SelectString(-1,"Latched");
return TRUE; // return TRUE unless you set the focus to a control
}
void CRegIsaIntExeDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// 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 CRegIsaIntExeDlg::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 CRegIsaIntExeDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CRegIsaIntExeDlg::OnConnectInt()
{
BOOL m_bTrigManner;
CString tmp,strIrqNum;
GetDlgItemText(IDC_IRQ_NUM_COMBO, tmp);
tmp.TrimLeft(" ");
if(tmp.IsEmpty())
{
AfxMessageBox("Irq number must be selected!.", MB_OK, NULL);
GetDlgItem(IDC_IRQ_NUM_COMBO)->SetFocus();
return;
}
// AfxMessageBox(tmp);
strIrqNum=tmp;
unsigned short m_IrqNum=(unsigned short)(atoi(strIrqNum));
//strIrqNum.Format("%d",m_IrqNum);
//AfxMessageBox(strIrqNum);
GetDlgItemText(IDC_TRIG_MANNER,tmp);
tmp.TrimLeft(" ");
if(tmp.IsEmpty())
{
AfxMessageBox("Trigger manner must be selected!.", MB_OK, NULL);
GetDlgItem(IDC_TRIG_MANNER)->SetFocus();
return;
}
//AfxMessageBox(tmp);
if(tmp=="Latched")
{
m_bTrigManner=TRUE;
}
else
m_bTrigManner=FALSE;
AfxBeginThread(ThreadListen,GetSafeHwnd(),THREAD_PRIORITY_NORMAL);
if(isa_int.ConnectInterrupt(m_IrqNum,m_bTrigManner)==TRUE)
{
ulIntTimes=0;
bListen=TRUE;
SetDlgItemText(IDC_SUCCESS_FLAG,"Success to connect interrupt!");
}
else
{
bListen=FALSE;
SetDlgItemText(IDC_SUCCESS_FLAG,"Failed to connect interrupt!");
}
}
void CRegIsaIntExeDlg::OnDisconnectInt()
{
ulIntTimes=0;
bListen=FALSE;
// TODO: Add your control notification handler code here
isa_int.DisConnectInt(0,TRUE);
SetDlgItemText(IDC_SUCCESS_FLAG,"Interrupt disconnected!");
}
void CRegIsaIntExeDlg::OnEventCome(WPARAM w,LPARAM l)
{
m_dIntTimes=(ULONG)w;
// AfxMessageBox(m_dIntTimes);
UpdateData(FALSE);
}
void CRegIsaIntExeDlg::OnSelchangeIrqNumCombo()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString tmp;
int index;
index=m_dIrqNum.GetCurSel();
m_dIrqNum.GetLBText(index,tmp);
//AfxMessageBox(tmp);
unsigned short m_IrqNum=(unsigned short)(atoi(tmp));
switch(m_IrqNum)
{
case 0:
m_dIntName="Systme timer";
break;
case 1:
m_dIntName="Keyboard";
break;
case 3:
m_dIntName="Serial Comms. COM2/COM4";
break;
case 4:
m_dIntName="Serial Comms. COM1/COM3";
break;
case 5:
m_dIntName="Reserved/Sound Card";
break;
case 6:
m_dIntName="Floppy Disk Controller";
break;
case 7:
m_dIntName="Parallel Comms";
break;
case 8:
m_dIntName="Real Time Clock";
break;
case 9:
m_dIntName="Redirected IRQ2";
break;
case 10:
m_dIntName="Reserved";
break;
case 11:
m_dIntName="Reserved";
break;
case 12:
m_dIntName="PS/2 Mouse";
break;
case 13:
m_dIntName="Math's Co-Processor";
break;
case 14:
m_dIntName="Hard Disk Drive";
break;
case 15:
m_dIntName="Reserved";
break;
}
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -