?? dlgcomset.cpp
字號:
// DlgComSet.cpp : implementation file
//
#include "stdafx.h"
#include "VideoCapture.h"
#include "DlgComSet.h"
#include "VideoCaptureView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgComSet dialog
CDlgComSet::CDlgComSet(CWnd* pParent /*=NULL*/)
: CDialog(CDlgComSet::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgComSet)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDlgComSet::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgComSet)
DDX_Control(pDX, IDC_COMM_SELECT, m_com);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgComSet, CDialog)
//{{AFX_MSG_MAP(CDlgComSet)
ON_WM_SHOWWINDOW()
ON_CBN_CLOSEUP(IDC_COMM_SELECT, OnCloseupCommSelect)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgComSet message handlers
void CDlgComSet::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
CVideoCaptureView* pView=CVideoCaptureView::GetView();
if(pView)
pView->IsCapturing=TRUE;
}
void CDlgComSet::OnOK()
{
CString com;
CString comName;
m_com.GetWindowText(com);
comName=com;
com=com.Right(1);
CVideoCaptureView* pView=CVideoCaptureView::GetView();
if(!pView) return;
if (!pView->ZDJC)
{
if(pView->ComOpen(atoi(com)))
{
::WritePrivateProfileString("SYSTEM","COM",com,".\\config.ini");
pView->m_CommPort=atoi(com);
}
}
else
{
}
EndDialog(0);
}
BOOL CDlgComSet::OnInitDialog()
{
CDialog::OnInitDialog();
HKEY hKEY;
long hResult=::RegOpenKeyEx(HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM",0,KEY_READ,&hKEY);
if(hResult!=ERROR_SUCCESS)//如果無法打開hKEY,則中止程序的執行
{
ShowMessage("錯誤:無法打開有關注冊表項");
return FALSE;
}
char owner_Get[20],str[30];
DWORD type_1=REG_SZ;
DWORD cbData_1=20;
DWORD aa=30,num=0,a1,a2,a3,a4,a5,a6,a7;
hResult=::RegQueryInfoKey(hKEY,str,&a7,NULL,&a3,&a1,&a2,&num,&a4,&a5,&a6,NULL);
if(hResult!=ERROR_SUCCESS)//如果無法打開hKEY,則中止程序的執行
{
ShowMessage("錯誤:無法打開有關注冊表項");
return FALSE;
}
// hResult=RegQueryValueEx(hKEY,"\\Device\\Serial0",NULL,&type_1,(BYTE*)str,&aa);
for(DWORD i=0;i<num;i++)
{
aa=30;cbData_1=20;
hResult=::RegEnumValue(hKEY,i,str,&aa,NULL,&type_1,(BYTE*)owner_Get,&cbData_1);
if(hResult==ERROR_SUCCESS)//如果無法打開hKEY,則中止程序的執行
{
m_com.AddString(owner_Get);
}
}
RegCloseKey(hKEY);
int a=::GetPrivateProfileInt("SYSTEM","COM",4,".\\config.ini");
CString com;
com.Format("COM%d",a);
m_com.SelectString(0,com);
// GetDlgItem(IDC_EDIT_STATUS)->SetWindowText("正在測試中");
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgComSet::OnCloseupCommSelect()
{
// GetDlgItem(IDC_EDIT_STATUS)->SetWindowText("正在測試中");
CString com;
m_com.GetWindowText(com);
com=com.Right(1);
CVideoCaptureView* pView=CVideoCaptureView::GetView();
if(!pView)
return;
if (!pView->ZDJC) {
if(pView->ComOpen(atoi(com)))
{
::WritePrivateProfileString("SYSTEM","COM",com,".\\config.ini");
pView->m_CommPort=atoi(com);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -