當主對話框初始化時,創(chuàng)建預覽窗口的父窗口,判斷使用的顯卡類型并初始化SDK開發(fā)包。代碼如下:
BOOL CCaptureDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CButton* pBmpButton = (CButton*) GetDlgItem(IDC_BMP);
//……此處代碼省略
CString strTemp;
m_Frame.Create(IDD_PANEL_DIALOG,NULL); //創(chuàng)建預覽窗口的父窗口
CRect rc;
GetWindowRect(rc); //獲得主窗口的客戶區(qū)域
//設置預覽窗口的父窗口的顯示區(qū)域
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文件中的數(shù)據(jù)
GetPrivateProfileString("顯卡設置","類型","VGA" ,str.GetBuffer(0), 10, "./syssetting.ini");
BOOL ret;
if(str=="VGA") //判斷是否選擇了VGA顯卡
{
pVGAButton->SetCheck(1); //設置VGA按鈕選中
pPCIButton->SetCheck(0); //設置PCI按鈕未選中
//初始化SDK開發(fā)包
ret = VCAInitSdk(m_Frame.m_hWnd,PCI_VIEDOMEMORY);
}
else
{
ret = VCAInitSdk(m_Frame.m_hWnd,PCI_MEMORY_VIDEOMEMORY); //初始化SDK開發(fā)包
pVGAButton->SetCheck(0); //設置VGA按鈕未選中
pPCIButton->SetCheck(1); //設置PCI按鈕選中
}
if(ret) //判斷初始化SDK開發(fā)包是否成功
{
//獲得幾路視頻
m_DevNum = VCAGetDevNum();
m_Frame.CreatePreWnd((int)sqrt(m_DevNum)); //根據(jù)獲得路數(shù)創(chuàng)建視頻預覽窗口
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;
}