当主对话框初始化时,创建预览窗口的父窗口,判断使用的显卡类型并初始化SDK开发包。代码如下:
BOOL CCaptureDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CButton* pBmpButton = (CButton*) GetDlgItem(IDC_BMP);
//……此处代码省略
CString strTemp;
m_Frame.Create(IDD_PANEL_DIALOG,NULL); //创建预览窗口的父窗口
CRect rc;
GetWindowRect(rc); //获得主窗口的客户区域
//设置预览窗口的父窗口的显示区域
m_Frame.SetWindowPos(&wndTop,0,0,rc.Width()-180,rc.Height()-10,SWP_SHOWWINDOW);
m_Frame.ShowWindow(SW_SHOW); //显示预览窗口的父窗口
CButton* pVGAButton = (CButton*) GetDlgItem(IDC_VGA);
CButton* pPCIButton = (CButton*) GetDlgItem(IDC_PCI);
CString str= "temp";
//读取INI文件中的数据
GetPrivateProfileString("显卡设置","类型","VGA" ,str.GetBuffer(0), 10, "./syssetting.ini");
BOOL ret;
if(str=="VGA") //判断是否选择了VGA显卡
{
pVGAButton->SetCheck(1); //设置VGA按钮选中
pPCIButton->SetCheck(0); //设置PCI按钮未选中
//初始化SDK开发包
ret = VCAInitSdk(m_Frame.m_hWnd,PCI_VIEDOMEMORY);
}
else
{
ret = VCAInitSdk(m_Frame.m_hWnd,PCI_MEMORY_VIDEOMEMORY); //初始化SDK开发包
pVGAButton->SetCheck(0); //设置VGA按钮未选中
pPCIButton->SetCheck(1); //设置PCI按钮选中
}
if(ret) //判断初始化SDK开发包是否成功
{
//获得几路视频
m_DevNum = VCAGetDevNum();
m_Frame.CreatePreWnd((int)sqrt(m_DevNum)); //根据获得路数创建视频预览窗口
for (int i = 0; i<m_DevNum; i++)
{
VCAOpenDevice(i,m_Frame.m_pList[i].m_hWnd); //打开视频预览窗口
BOOL ret = VCAStartVideoPreview(i); //开始预览
m_Frame.UpdateAllPreView(); //更新视频预览窗口
}
m_BStop = FALSE;
}
SetTimer(1,1000,NULL); //设置定时器
return TRUE;
}