SelectDriverDialog.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:3k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // SelectDriverDialog.cpp : implementation file
- //
- #include "stdafx.h"
- #include "vfw.h"
- #include "SelectDriverDialog.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #pragma comment( lib , "vfw32.lib" )
- /////////////////////////////////////////////////////////////////////////////
- // CSelectDriverDialog dialog
- CSelectDriverDialog::CSelectDriverDialog(CWnd* pParent /*=NULL*/)
- : CDialog(CSelectDriverDialog::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSelectDriverDialog)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CSelectDriverDialog::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSelectDriverDialog)
- DDX_Control(pDX, IDC_LIST, m_list);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CSelectDriverDialog, CDialog)
- //{{AFX_MSG_MAP(CSelectDriverDialog)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSelectDriverDialog message handlers
- BOOL CSelectDriverDialog::OnInitDialog()
- {
- CDialog::OnInitDialog();
- //获取视频驱动器
- HWND hWnd = ::capCreateCaptureWindow( "本地视频窗口" ,WS_OVERLAPPEDWINDOW , 0 , 0 , 1 , 1 , NULL , 0 );
- //查找所有的驱动
- CString name, version;
- for( int i = 0; i < 10 ; i++ )
- if( capDriverConnect( hWnd , i ) )
- {
- capDriverGetName( hWnd , name.GetBufferSetLength( MAX_PATH ) , MAX_PATH );
- name.ReleaseBuffer( );
- capDriverGetVersion( hWnd , version.GetBufferSetLength( MAX_PATH ) , MAX_PATH );
- version.ReleaseBuffer( );
- capDriverDisconnect( hWnd );
- //添加到链表
- int index = this->m_list.AddString( name+", " + version );
- this->m_list.SetItemData( index , i );
- }
- else if( this->driver_id == i )
- this->driver_id = -1;
- //清除窗口
- ::DestroyWindow( hWnd );
- if( this->driver_id != -1 || ! this->m_list.GetCount( ) )
- {
- if( this->driver_id == -1 )
- MessageBox( "没有视频驱动设备" , "视频驱动" , MB_ICONINFORMATION | MB_OK );
- CSelectDriverDialog::OnCancel( );
- }
- else if( this->m_list.GetCount( ) == 1 )
- {
- this->m_list.SetCurSel( 0 );
- CSelectDriverDialog::OnOK( );
- }
- return TRUE;
- }
- void CSelectDriverDialog::OnOK()
- {
- int index = this->m_list.GetCurSel( );
- if( index == CB_ERR )
- {
- MessageBox( "请从列表中选择一个视频驱动器" , "视频驱动" , MB_ICONSTOP | MB_OK );
- return;
- }
- this->driver_id = this->m_list.GetItemData( index );
- CDialog::OnOK( );
- }
- int CSelectDriverDialog::SelectDriver( int driver_id )
- {
- CSelectDriverDialog dlg;
- dlg.driver_id = driver_id;
- dlg.DoModal( );
- return dlg.driver_id;
- }