CaptureDlg.cpp
上传用户:connie527
上传日期:2022-04-15
资源大小:4326k
文件大小:34k
源码类别:

行业应用

开发平台:

Visual C++

  1. // CaptureDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "Capture.h"
  5. #include "CaptureDlg.h"
  6. #include "ControlForm.h"
  7. #include "Autodlg.h"
  8. #include "Playdlg.h"
  9. #include "Login.h"
  10. #include "Managedlg.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CAboutDlg dialog used for App About
  18. class CAboutDlg : public CDialog
  19. {
  20. public:
  21. CAboutDlg();
  22. // Dialog Data
  23. //{{AFX_DATA(CAboutDlg)
  24. enum { IDD = IDD_ABOUTBOX };
  25. //}}AFX_DATA
  26. // ClassWizard generated virtual function overrides
  27. //{{AFX_VIRTUAL(CAboutDlg)
  28. protected:
  29. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  30. //}}AFX_VIRTUAL
  31. // Implementation
  32. protected:
  33. //{{AFX_MSG(CAboutDlg)
  34. //}}AFX_MSG
  35. DECLARE_MESSAGE_MAP()
  36. };
  37. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  38. {
  39. //{{AFX_DATA_INIT(CAboutDlg)
  40. //}}AFX_DATA_INIT
  41. }
  42. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CDialog::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(CAboutDlg)
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  49. //{{AFX_MSG_MAP(CAboutDlg)
  50. // No message handlers
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CCaptureDlg dialog
  55. CCaptureDlg::CCaptureDlg(CWnd* pParent /*=NULL*/)
  56. : CDialog(CCaptureDlg::IDD, pParent)
  57. {
  58. //{{AFX_DATA_INIT(CCaptureDlg)
  59. //}}AFX_DATA_INIT
  60. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  61. m_hIcon        = AfxGetApp()->LoadIcon(IDI_ICON1);
  62. m_CapitonColor = RGB(0,0,255);
  63. m_Caption      = "社区视频监控系统";
  64. m_IsMax        = TRUE;
  65. m_Time         = FALSE;
  66. m_Kinescope    = FALSE;
  67. m_Cancel       = FALSE;
  68. }
  69. void CCaptureDlg::DoDataExchange(CDataExchange* pDX)
  70. {
  71. CDialog::DoDataExchange(pDX);
  72. //{{AFX_DATA_MAP(CCaptureDlg)
  73. DDX_Control(pDX, IDC_REBRUSH, m_ReBrush);
  74. DDX_Control(pDX, IDC_INBRUSH, m_InBrush);
  75. DDX_Control(pDX, IDC_INAPERTURE, m_InAperture);
  76. DDX_Control(pDX, IDC_REAPERTURE, m_ReAperture);
  77. DDX_Control(pDX, IDC_RELEN, m_ReLen);
  78. DDX_Control(pDX, IDC_INLEN, m_InLen);
  79. DDX_Control(pDX, IDC_REFOCI, m_ReFoci);
  80. DDX_Control(pDX, IDC_INFOCI, m_InFoci);
  81. DDX_Control(pDX, IDC_BUTTONRIGHT, m_ButtonRight);
  82. DDX_Control(pDX, IDC_BUTTONLEFT, m_ButtonLeft);
  83. DDX_Control(pDX, IDC_BUTTONUP, m_ButtonUp);
  84. DDX_Control(pDX, IDC_BUTTONDOWN, m_ButtonDown);
  85. DDX_Control(pDX, IDC_MSCOMM1, m_Com);
  86. //}}AFX_DATA_MAP
  87. }
  88. BEGIN_MESSAGE_MAP(CCaptureDlg, CDialog)
  89. //{{AFX_MSG_MAP(CCaptureDlg)
  90. ON_WM_SYSCOMMAND()
  91. ON_WM_PAINT()
  92. ON_WM_QUERYDRAGICON()
  93. ON_WM_TIMER()
  94. ON_WM_SIZE()
  95. ON_BN_CLICKED(IDC_SNAPSHOT, OnSnapshot)
  96. ON_WM_WINDOWPOSCHANGED()
  97. ON_BN_CLICKED(IDC_BMP, OnBmp)
  98. ON_BN_CLICKED(IDC_JPG, OnJpg)
  99. ON_BN_CLICKED(IDC_VGA, OnVga)
  100. ON_BN_CLICKED(IDC_PCI, OnPci)
  101. ON_BN_CLICKED(IDC_SETTING, OnSetting)
  102. ON_WM_CTLCOLOR()
  103. ON_WM_NCMOUSEMOVE()
  104. ON_WM_MOUSEMOVE()
  105. ON_WM_NCLBUTTONDOWN()
  106. ON_WM_NCACTIVATE()
  107. ON_BN_CLICKED(IDC_CONTROL, OnControl)
  108. ON_BN_CLICKED(IDC_AUTOMATISM, OnAutomatism)
  109. ON_BN_CLICKED(IDC_STOP, OnStop)
  110. ON_BN_CLICKED(IDC_KINESCOPE, OnKinescope)
  111. ON_BN_CLICKED(IDC_PLAY, OnPlay)
  112. ON_BN_CLICKED(IDC_MANAGE, OnManage)
  113. //}}AFX_MSG_MAP
  114. END_MESSAGE_MAP()
  115. /////////////////////////////////////////////////////////////////////////////
  116. // CCaptureDlg message handlers
  117. BOOL CCaptureDlg::OnInitDialog()
  118. {
  119. CDialog::OnInitDialog();
  120. CButton* pBmpButton = (CButton*) GetDlgItem(IDC_BMP);
  121. pBmpButton->SetCheck(1);
  122. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  123. ASSERT(IDM_ABOUTBOX < 0xF000);
  124. CMenu* pSysMenu = GetSystemMenu(FALSE);
  125. if (pSysMenu != NULL)
  126. {
  127. CString strAboutMenu;
  128. strAboutMenu.LoadString(IDS_ABOUTBOX);
  129. if (!strAboutMenu.IsEmpty())
  130. {
  131. pSysMenu->AppendMenu(MF_SEPARATOR);
  132. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  133. }
  134. }
  135. SetIcon(m_hIcon, TRUE);
  136. SetIcon(m_hIcon, FALSE);
  137. CLogin dlg;
  138. if(dlg.DoModal() != IDOK)
  139. {
  140. m_Cancel = TRUE;
  141. CDialog::OnCancel();
  142. }
  143. char buf[256];
  144. ::GetCurrentDirectory(256,buf);
  145. m_PathText.Format("%s",buf);
  146. m_UserName = dlg.m_Name;
  147. m_LogTime = CTime::GetCurrentTime();
  148. CString strText;
  149. strText.Format("%st%st登录rn",m_UserName,m_LogTime.Format("%y-%m-%d %H:%M:%S"));
  150. strcat(buf,"\log.txt");
  151. m_LogPath.Format("%s",buf);
  152. CFile file;
  153. file.Open(m_LogPath,CFile::modeWrite);
  154. file.SeekToEnd();
  155. file.Write(strText,strText.GetLength());
  156. file.Close();
  157. //加载背景位图
  158. m_BKGround.LoadBitmap(IDB_BKGROUND);
  159. m_BorderHeight  = GetSystemMetrics(SM_CYBORDER);
  160. m_BorderWidth   = GetSystemMetrics(SM_CXBORDER);
  161. m_CaptionHeight = GetSystemMetrics(SM_CYCAPTION);
  162. SetWindowText(m_Caption);
  163. m_CaptionFont.CreateFont(14,10,0,3,600,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
  164. CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_ROMAN,"宋体");
  165. CBitmap bitmap;
  166. bitmap.LoadBitmap(IDB_MINBT);
  167. BITMAPINFO bInfo;
  168. bitmap.GetObject(sizeof(bInfo),&bInfo);
  169. m_ButtonWidth = bInfo.bmiHeader.biWidth;
  170. m_ButtonHeight = bInfo.bmiHeader.biHeight;
  171. bitmap.DeleteObject();
  172. CString strTemp;
  173. m_Frame.Create(IDD_PANEL_DIALOG,NULL);
  174. CRect rc;
  175. GetWindowRect(rc);
  176. m_Frame.SetWindowPos(&wndTop,0,0,rc.Width()-180,rc.Height()-10,SWP_SHOWWINDOW);
  177. m_Frame.ShowWindow(SW_SHOW);
  178. CButton* pVGAButton = (CButton*) GetDlgItem(IDC_VGA);
  179. CButton* pPCIButton = (CButton*) GetDlgItem(IDC_PCI);
  180. CString str= "temp";
  181. GetPrivateProfileString("显卡设置","类型","VGA" ,str.GetBuffer(0), 10, "./syssetting.ini");
  182. BOOL ret;
  183. if(str=="VGA")
  184. {
  185. pVGAButton->SetCheck(1);
  186. pPCIButton->SetCheck(0);
  187. //初始化SDK
  188. ret = VCAInitSdk(m_Frame.m_hWnd,PCI_VIEDOMEMORY);
  189. }
  190. else
  191. {
  192. ret = VCAInitSdk(m_Frame.m_hWnd,PCI_MEMORY_VIDEOMEMORY);
  193. pVGAButton->SetCheck(0);
  194. pPCIButton->SetCheck(1);
  195. }
  196. if(ret)
  197. {
  198. //获得几路视频
  199. m_DevNum = VCAGetDevNum();
  200. m_Frame.CreatePreWnd((int)sqrt(m_DevNum));
  201. for (int i = 0; i<m_DevNum; i++)
  202. {
  203. VCAOpenDevice(i,m_Frame.m_pList[i].m_hWnd);
  204. BOOL ret = VCAStartVideoPreview(i);
  205. m_Frame.UpdateAllPreView();
  206. }
  207. m_BStop = FALSE;
  208. }
  209. SetTimer(1,1000,NULL);
  210. m_ButtonUp.m_Type    = ctUp;
  211. m_ButtonDown.m_Type  = ctDown;
  212. m_ButtonLeft.m_Type  = ctLeft;
  213. m_ButtonRight.m_Type = ctRight;
  214. m_InFoci.m_Type      = ctInFoci;
  215. m_ReFoci.m_Type      = ctReFoci;
  216. m_InLen.m_Type       = ctInLen;
  217. m_ReLen.m_Type       = ctReLen;
  218. m_InAperture.m_Type  = ctInAperture;
  219. m_ReAperture.m_Type  = ctReAperture;
  220. m_InBrush.m_Type     = ctInBrush;
  221. m_ReBrush.m_Type     = ctReBrush;
  222. m_Len = GetPrivateProfileInt("使用字节数","字节数",8,"./stage.ini");
  223. m_ActoinCount = GetPrivateProfileInt("控制项","控制数",13,"./stage.ini");
  224. m_pData = new  unsigned char[m_ActoinCount][MAXNUM];
  225. m_Port = GetPrivateProfileInt("端口设置","端口号",1,"./stage.ini");
  226. GetPrivateProfileString("端口设置","环境设置","9600,n,8,1",
  227. m_Setting.GetBuffer(0),MAX_PATH,"./stage.ini");
  228. int data;
  229. char buff[20] = {0};
  230. char var[20]  = {0};
  231. for (int i = 0 ; i<m_ActoinCount ; i++)
  232. {
  233. for (int j = 0 ; j <m_Len; j++)
  234. {
  235. char section[20] = "字节";
  236. itoa(i+1,var,10);
  237. itoa(j+1,buff,10);
  238. strcat(section,buff);
  239. data = GetPrivateProfileInt(var,section,0,"./stage.ini");
  240. m_pData[i][j] = data;
  241. }
  242. }
  243. //设置端口信息,并打开端口
  244. m_Com.SetSettings(m_Setting);
  245. m_Com.SetOutBufferSize(512);
  246. m_Com.SetCommPort(m_Port);
  247. m_Com.SetSThreshold(0);
  248. m_Com.SetPortOpen(TRUE);
  249. return TRUE; 
  250. }
  251. void CCaptureDlg::OnSysCommand(UINT nID, LPARAM lParam)
  252. {
  253. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  254. {
  255. CAboutDlg dlgAbout;
  256. dlgAbout.DoModal();
  257. }
  258. else
  259. {
  260. CDialog::OnSysCommand(nID, lParam);
  261. }
  262. }
  263. // If you add a minimize button to your dialog, you will need the code below
  264. //  to draw the icon.  For MFC applications using the document/view model,
  265. //  this is automatically done for you by the framework.
  266. void CCaptureDlg::OnPaint() 
  267. {
  268. if (IsIconic())
  269. {
  270. CPaintDC dc(this); // device context for painting
  271. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  272. // Center icon in client rectangle
  273. int cxIcon = GetSystemMetrics(SM_CXICON);
  274. int cyIcon = GetSystemMetrics(SM_CYICON);
  275. CRect rect;
  276. GetClientRect(&rect);
  277. int x = (rect.Width() - cxIcon + 1) / 2;
  278. int y = (rect.Height() - cyIcon + 1) / 2;
  279. // Draw the icon
  280. dc.DrawIcon(x, y, m_hIcon);
  281. }
  282. else
  283. {
  284. CDialog::OnPaint();
  285. }
  286. DrawDialog(FALL);
  287. m_IsDrawForm = TRUE;
  288. }
  289. // The system calls this to obtain the cursor to display while the user drags
  290. //  the minimized window.
  291. HCURSOR CCaptureDlg::OnQueryDragIcon()
  292. {
  293. return (HCURSOR) m_hIcon;
  294. }
  295. void CCaptureDlg::OnCancel()
  296. {
  297. for(int i=0;i<m_DevNum;i++)
  298. VCACloseDevice(i);
  299. VCAUnInitSdk();
  300. CDialog::OnCancel();
  301. }
  302. void CCaptureDlg::OnTimer(UINT nIDEvent) 
  303. {
  304. //判断某一路是否有信号
  305. eFieldFrequency frequency;
  306. for (int i=0;i<m_DevNum;i++)
  307. {
  308. VCAGetVidFieldFrq(i,frequency);
  309. if(frequency == FIELD_FREQ_0HZ)  //无信号
  310. {
  311. if (m_Frame.m_pList[i].m_ShowImage == TRUE)
  312. {
  313. m_Frame.m_pList[i].m_ShowImage = FALSE;
  314. m_Frame.m_pList[i].Invalidate();
  315. }
  316. }
  317. else
  318. {
  319. if(m_Frame.m_pList[i].m_ShowImage == FALSE)
  320. {
  321. m_Frame.m_pList[i].m_ShowImage = TRUE;
  322. m_Frame.m_pList[i].Invalidate();
  323. if(m_Frame.m_pList[i].m_Stop == psPreview)
  324. {
  325. VCAUpdateOverlayWnd(m_Frame.m_hWnd);
  326. VCAUpdateVideoPreview(i,m_Frame.m_pList[i].m_hWnd);
  327. }
  328. }
  329. }
  330. }
  331. if(m_Time)
  332. {
  333. CTime time= CTime::GetCurrentTime();
  334. if(time == m_StopTime)
  335. {
  336. OnStop();
  337. m_Time = FALSE;
  338. }
  339. }
  340. CDialog::OnTimer(nIDEvent);
  341. }
  342. void CCaptureDlg::OnSize(UINT nType, int cx, int cy) 
  343. {
  344. CDialog::OnSize(nType, cx, cy);
  345. CPoint pos(30,1);
  346. m_MinRect.CopyRect(CRect(m_RTitleRc.left+pos.x,(m_TitleDrawHeight 
  347. +2*m_BorderHeight -m_ButtonHeight)/2+pos.y,m_ButtonWidth,m_ButtonHeight));
  348. pos.x = 55;
  349. m_MaxRect.CopyRect(CRect(m_RTitleRc.left+pos.x,(m_TitleDrawHeight
  350. +2*m_BorderHeight -m_ButtonHeight)/2+pos.y,m_ButtonWidth,m_ButtonHeight));
  351. pos.x = 80;
  352. m_CloseRect.CopyRect(CRect(m_RTitleRc.left+pos.x,(m_TitleDrawHeight
  353. +2*m_BorderHeight -m_ButtonHeight)/2+pos.y,m_ButtonWidth,m_ButtonHeight));
  354. Invalidate();
  355. CRect rc,frc;
  356. GetClientRect(rc);
  357. CRect rcconctrl;
  358. GetDlgItem(IDC_STATIC1)->GetClientRect(rcconctrl);
  359. GetDlgItem(IDC_STATIC1)->MoveWindow(rc.Width()-170,rc.top+55,
  360. rcconctrl.Width(),rcconctrl.Height());
  361. GetDlgItem(IDC_STATIC2)->GetClientRect(rcconctrl);
  362. GetDlgItem(IDC_STATIC2)->MoveWindow(rc.Width()-170,rc.top+255,
  363. rcconctrl.Width(),rcconctrl.Height());
  364. GetDlgItem(IDC_REFOCI)->GetClientRect(rcconctrl);
  365. GetDlgItem(IDC_REFOCI)->MoveWindow(rc.Width()-150,rc.top+80,
  366. rcconctrl.Width(),rcconctrl.Height());
  367. GetDlgItem(IDC_RELEN)->GetClientRect(rcconctrl);
  368. GetDlgItem(IDC_RELEN)->MoveWindow(rc.Width()-150,rc.top+120,
  369. rcconctrl.Width(),rcconctrl.Height());
  370. GetDlgItem(IDC_REAPERTURE)->GetClientRect(rcconctrl);
  371. GetDlgItem(IDC_REAPERTURE)->MoveWindow(rc.Width()-150,rc.top+160,
  372. rcconctrl.Width(),rcconctrl.Height());
  373. GetDlgItem(IDC_REBRUSH)->GetClientRect(rcconctrl);
  374. GetDlgItem(IDC_REBRUSH)->MoveWindow(rc.Width()-150,rc.top+200,
  375. rcconctrl.Width(),rcconctrl.Height());
  376. GetDlgItem(IDC_INFOCI)->GetClientRect(rcconctrl);
  377. GetDlgItem(IDC_INFOCI)->MoveWindow(rc.Width()-80,rc.top+80,
  378. rcconctrl.Width(),rcconctrl.Height());
  379. GetDlgItem(IDC_INLEN)->GetClientRect(rcconctrl);
  380. GetDlgItem(IDC_INLEN)->MoveWindow(rc.Width()-80,rc.top+120,
  381. rcconctrl.Width(),rcconctrl.Height());
  382. GetDlgItem(IDC_INAPERTURE)->GetClientRect(rcconctrl);
  383. GetDlgItem(IDC_INAPERTURE)->MoveWindow(rc.Width()-80,rc.top+160,
  384. rcconctrl.Width(),rcconctrl.Height());
  385. GetDlgItem(IDC_INBRUSH)->GetClientRect(rcconctrl);
  386. GetDlgItem(IDC_INBRUSH)->MoveWindow(rc.Width()-80,rc.top+200,
  387. rcconctrl.Width(),rcconctrl.Height());
  388. GetDlgItem(IDC_BUTTONUP)->GetClientRect(rcconctrl);
  389. GetDlgItem(IDC_BUTTONUP)->MoveWindow(rc.Width()-110,rc.top+270,
  390. rcconctrl.Width(),rcconctrl.Height());
  391. GetDlgItem(IDC_MSCOMM1)->GetClientRect(rcconctrl);
  392. GetDlgItem(IDC_MSCOMM1)->MoveWindow(rc.Width()-110,rc.top+320,
  393. rcconctrl.Width(),rcconctrl.Height());
  394. GetDlgItem(IDC_BUTTONDOWN)->GetClientRect(rcconctrl);
  395. GetDlgItem(IDC_BUTTONDOWN)->MoveWindow(rc.Width()-110,rc.top+370,
  396. rcconctrl.Width(),rcconctrl.Height());
  397. GetDlgItem(IDC_BUTTONLEFT)->GetClientRect(rcconctrl);
  398. GetDlgItem(IDC_BUTTONLEFT)->MoveWindow(rc.Width()-160,rc.top+320,
  399. rcconctrl.Width(),rcconctrl.Height());
  400. GetDlgItem(IDC_BUTTONRIGHT)->GetClientRect(rcconctrl);
  401. GetDlgItem(IDC_BUTTONRIGHT)->MoveWindow(rc.Width()-60,rc.top+320,
  402. rcconctrl.Width(),rcconctrl.Height());
  403. GetDlgItem(IDC_CONTROL)->GetClientRect(rcconctrl);
  404. GetDlgItem(IDC_CONTROL)->MoveWindow(rc.Width()-170,rc.top+435,
  405. rcconctrl.Width(),rcconctrl.Height());
  406. GetDlgItem(IDC_KINESCOPE)->GetClientRect(rcconctrl);
  407. GetDlgItem(IDC_KINESCOPE)->MoveWindow(rc.Width()-170,rc.top+470,
  408. rcconctrl.Width(),rcconctrl.Height());
  409. GetDlgItem(IDC_SNAPSHOT)->GetClientRect(rcconctrl);
  410. GetDlgItem(IDC_SNAPSHOT)->MoveWindow(rc.Width()-170,rc.top+505,
  411. rcconctrl.Width(),rcconctrl.Height());
  412. GetDlgItem(IDC_AUTOMATISM)->GetClientRect(rcconctrl);
  413. GetDlgItem(IDC_AUTOMATISM)->MoveWindow(rc.Width()-170,rc.top+575,
  414. rcconctrl.Width(),rcconctrl.Height());
  415. GetDlgItem(IDC_MANAGE)->GetClientRect(rcconctrl);
  416. GetDlgItem(IDC_MANAGE)->MoveWindow(rc.Width()-85,rc.top+435,
  417. rcconctrl.Width(),rcconctrl.Height());
  418. GetDlgItem(IDC_PLAY)->GetClientRect(rcconctrl);
  419. GetDlgItem(IDC_PLAY)->MoveWindow(rc.Width()-85,rc.top+470,
  420. rcconctrl.Width(),rcconctrl.Height());
  421. GetDlgItem(IDC_SETTING)->GetClientRect(rcconctrl);
  422. GetDlgItem(IDC_SETTING)->MoveWindow(rc.Width()-85,rc.top+505,
  423. rcconctrl.Width(),rcconctrl.Height());
  424. GetDlgItem(IDC_STOP)->GetClientRect(rcconctrl);
  425. GetDlgItem(IDC_STOP)->MoveWindow(rc.Width()-85,rc.top+575,
  426. rcconctrl.Width(),rcconctrl.Height());
  427. GetDlgItem(IDC_BMP)->GetClientRect(rcconctrl);
  428. GetDlgItem(IDC_BMP)->MoveWindow(rc.Width()-172,rc.top+540,
  429. rcconctrl.Width(),rcconctrl.Height());
  430. GetDlgItem(IDC_JPG)->GetClientRect(rcconctrl);
  431. GetDlgItem(IDC_JPG)->MoveWindow(rc.Width()-133,rc.top+540,
  432. rcconctrl.Width(),rcconctrl.Height());
  433. GetDlgItem(IDC_VGA)->GetClientRect(rcconctrl);
  434. GetDlgItem(IDC_VGA)->MoveWindow(rc.Width()-87,rc.top+540,
  435. rcconctrl.Width(),rcconctrl.Height());
  436. GetDlgItem(IDC_PCI)->GetClientRect(rcconctrl);
  437. GetDlgItem(IDC_PCI)->MoveWindow(rc.Width()-48,rc.top+540,
  438. rcconctrl.Width(),rcconctrl.Height());
  439. m_Frame.SetWindowPos(&wndTop,0,0,rc.Width()-180,rc.Height()-10,SWP_SHOWWINDOW);
  440. m_Frame.GetClientRect(frc);
  441. m_Frame.SetWindowPos(NULL,0,7,frc.Width(),rc.Height()-8,0);
  442. m_Frame.ShowWindow(SW_SHOW);
  443. }
  444. void CCaptureDlg::OnOK() 
  445. {
  446. }
  447. void CCaptureDlg::OnSnapshot() 
  448. {
  449. if(CPreView::m_CurIndex != -1)
  450. {
  451. if(m_Frame.m_pList[CPreView::m_CurIndex].m_ShowImage)
  452. {
  453. CButton* pBmpButton = (CButton*)GetDlgItem(IDC_BMP);
  454. if(pBmpButton->GetCheck() != 0)
  455. {
  456. CFileDialog fDlg(FALSE,"bmp","bmp_001",OFN_HIDEREADONLY 
  457. | OFN_OVERWRITEPROMPT,"bmp|*.bmp",this);
  458. if(fDlg.DoModal() == IDOK)
  459. {
  460. CString fName = fDlg.GetPathName();
  461. VCASaveAsBmpFile(CPreView::m_CurIndex,fName);
  462. }
  463. }
  464. else
  465. {
  466. CFileDialog fDlg(FALSE,"jpg","jpg_001",OFN_HIDEREADONLY 
  467. | OFN_OVERWRITEPROMPT,"JPG|*.JPG",this);
  468. if(fDlg.DoModal() == IDOK)
  469. {
  470. CString fName = fDlg.GetPathName();
  471. VCASaveAsJpegFile(CPreView::m_CurIndex,fName);
  472. }
  473. }
  474. m_LogTime = CTime::GetCurrentTime();
  475. CString strText;
  476. strText.Format("%st%st快照rn",m_UserName,
  477. m_LogTime.Format("%y-%m-%d %H:%M:%S"));
  478. CFile file;
  479. file.Open(m_LogPath,CFile::modeWrite);
  480. file.SeekToEnd();
  481. file.Write(strText,strText.GetLength());
  482. file.Close();
  483. }
  484. else
  485. {
  486. MessageBox("当前选择的图像不能预览!","提示");
  487. }
  488. }
  489. }
  490. void CCaptureDlg::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) 
  491. {
  492. CDialog::OnWindowPosChanged(lpwndpos);
  493. if(!m_Cancel)
  494. {
  495. for (UINT i = 0 ; i< m_DevNum; i++)
  496. {
  497. if (m_Frame.m_pList[i].m_ShowImage)
  498. {
  499. if (m_Frame.m_pList[i].m_Stop==psStop)
  500. {
  501. VCAStopVideoPreview(i);
  502. VCAUpdateOverlayWnd(m_Frame.GetSafeHwnd());
  503. }
  504. else if (m_Frame.m_pList[i].m_Stop==psPreview)
  505. {
  506. m_Frame.m_pList[i].Invalidate();
  507. VCAUpdateOverlayWnd(m_Frame.m_hWnd);
  508. VCAUpdateVideoPreview(i,m_Frame.m_pList[i].m_hWnd);
  509. }
  510. }
  511. }
  512. }
  513. }
  514. void CCaptureDlg::OnBmp() 
  515. {
  516. CButton* pBmpButton = (CButton*)GetDlgItem(IDC_BMP);
  517. pBmpButton->SetCheck(1);
  518. CButton* pJpgButton = (CButton*)GetDlgItem(IDC_JPG);
  519. pJpgButton->SetCheck(0);
  520. }
  521. void CCaptureDlg::OnJpg() 
  522. {
  523. CButton* pJpgButton = (CButton*)GetDlgItem(IDC_JPG);
  524. pJpgButton->SetCheck(1);
  525. CButton* pBmpButton = (CButton*)GetDlgItem(IDC_BMP);
  526. pBmpButton->SetCheck(0);
  527. }
  528. void CCaptureDlg::OnVga() 
  529. {
  530. CButton* pVGAButton = (CButton*)GetDlgItem(IDC_VGA);
  531. pVGAButton->SetCheck(1);
  532. CButton* pPCIButton = (CButton*)GetDlgItem(IDC_PCI);
  533. pPCIButton->SetCheck(0);
  534. }
  535. void CCaptureDlg::OnPci() 
  536. {
  537. CButton* pVGAButton = (CButton*)GetDlgItem(IDC_VGA);
  538. pVGAButton->SetCheck(0);
  539. CButton* pPCIButton = (CButton*)GetDlgItem(IDC_PCI);
  540. pPCIButton->SetCheck(1);
  541. }
  542. void CCaptureDlg::OnSetting() 
  543. {
  544. CButton* pVGAButton = (CButton*)GetDlgItem(IDC_VGA);
  545. int sel = pVGAButton->GetCheck();
  546. if(sel)
  547. {
  548. WritePrivateProfileString("显卡设置","类型","VGA","./syssetting.ini");
  549. }
  550. else
  551. {
  552. WritePrivateProfileString("显卡设置","类型","PCI","./syssetting.ini");
  553. }
  554. m_LogTime = CTime::GetCurrentTime();
  555. CString strText;
  556. strText.Format("%st%st设置显卡类型rn",m_UserName,
  557. m_LogTime.Format("%y-%m-%d %H:%M:%S"));
  558. CFile file;
  559. file.Open(m_LogPath,CFile::modeWrite);
  560. file.SeekToEnd();
  561. file.Write(strText,strText.GetLength());
  562. file.Close();
  563. MessageBox("要使显卡设置生效,需要重新启动应用程序!","提示");
  564. }
  565. HBRUSH CCaptureDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
  566. {
  567. HBRUSH hbr;
  568. if(nCtlColor == CTLCOLOR_DLG)
  569. {
  570. //定义一个位图画刷
  571. CBrush m_Brush(&m_BKGround);
  572. CRect rect;
  573. GetClientRect(rect);
  574. //选中画刷
  575. pDC->SelectObject(&m_Brush);
  576. //填充客户区域
  577. pDC->FillRect(rect,&m_Brush);
  578. return m_Brush;
  579. }
  580. else 
  581. hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  582. return hbr;
  583. }
  584. void CCaptureDlg::DrawDialog(UINT Flags)
  585. {
  586. m_FrameHeight   = GetSystemMetrics(SM_CYFIXEDFRAME);
  587. m_BorderHeight  = GetSystemMetrics(SM_CYBORDER);
  588. m_FrameWidth    = GetSystemMetrics(SM_CXFIXEDFRAME);
  589. m_BorderWidth   = GetSystemMetrics(SM_CXBORDER);
  590. m_CaptionHeight = GetSystemMetrics(SM_CYCAPTION);
  591. CRect Clientrect;
  592. GetClientRect(Clientrect);
  593. CRect WinRC,FactRC;
  594. GetWindowRect(WinRC);
  595. FactRC.CopyRect(CRect(0,0,WinRC.Width(),WinRC.Height()));
  596. //获取窗口设备上下文
  597. CWindowDC WindowDC(this);
  598. CBitmap LeftLine,*OldObj;
  599. BITMAPINFO bitinfo;
  600. CDC memDC;
  601. memDC.CreateCompatibleDC(&WindowDC);
  602. int leftwidth     = 0; //左标题的宽度
  603. int rightwidth    = 0; //右标题的宽度
  604. int leftlinewidth = 0; //窗体边框和3D宽度
  605. int rLineWidth;
  606. int bLineHeight;
  607. DeleteObject(LeftLine);
  608. LeftLine.LoadBitmap(IDB_RIGHTTITLE); //加载右标题
  609. LeftLine.GetObject(sizeof(bitinfo),&bitinfo);
  610. rightwidth = bitinfo.bmiHeader.biWidth;
  611. LeftLine.Detach();
  612. int x,y;
  613. //绘制左边线
  614. //获取位图大小
  615. if(Flags & FLEFTBAR)
  616. {
  617. DeleteObject(LeftLine);
  618. LeftLine.LoadBitmap(IDB_LEFTBAR);
  619. LeftLine.GetObject(sizeof(bitinfo),&bitinfo);
  620. LeftLine.GetObject(sizeof(bitinfo),&bitinfo);
  621. x = bitinfo.bmiHeader.biWidth;
  622. y = bitinfo.bmiHeader.biHeight;
  623. OldObj = memDC.SelectObject(&LeftLine);
  624. //判断位图的宽度与窗体边缘的宽度
  625. leftlinewidth = (x> m_FrameWidth+m_BorderWidth)? x:m_FrameWidth+m_BorderWidth;
  626. WindowDC.StretchBlt(0,m_CaptionHeight,leftlinewidth,
  627. FactRC.Height()-m_CaptionHeight,&memDC,0,0,x,y,SRCCOPY);
  628. memDC.SelectObject(OldObj);
  629. LeftLine.Detach();
  630. }
  631. //绘制左标题
  632. if(Flags & FLEFTTITLE)
  633. {
  634. DeleteObject(LeftLine);
  635. LeftLine.LoadBitmap(IDB_LEFTTITLE);
  636. //获取位图大小
  637. LeftLine.GetObject(sizeof(bitinfo),&bitinfo);
  638. OldObj = memDC.SelectObject(&LeftLine);
  639. leftwidth = x = bitinfo.bmiHeader.biWidth;
  640. y = bitinfo.bmiHeader.biHeight;
  641. m_TitleDrawHeight = (m_CaptionHeight+4 > y) ? m_CaptionHeight+4 : y;
  642. m_LTitleRc.CopyRect(CRect(0,0,x,m_TitleDrawHeight));
  643. WindowDC.StretchBlt(m_LTitleRc.left,m_LTitleRc.top,m_LTitleRc.Width(),
  644. m_LTitleRc.Height(),&memDC,0,0,x,y,SRCCOPY);
  645. memDC.SelectObject(OldObj);
  646. LeftLine.Detach();
  647. }
  648. //绘制右标题
  649. if(Flags & FRIGHTTITLE)
  650. {
  651. DeleteObject(LeftLine);
  652. LeftLine.LoadBitmap(IDB_RIGHTTITLE);
  653. //获取位图大小
  654. LeftLine.GetObject(sizeof(bitinfo),&bitinfo);
  655. OldObj = memDC.SelectObject(&LeftLine);
  656. x = bitinfo.bmiHeader.biWidth;
  657. y = bitinfo.bmiHeader.biHeight;
  658. m_TitleDrawHeight = (m_CaptionHeight+4 > y) ? m_CaptionHeight+4 : y;
  659. m_RTitleRc.CopyRect(CRect(FactRC.right-x,0,FactRC.right,m_TitleDrawHeight));
  660. WindowDC.StretchBlt(m_RTitleRc.left,m_RTitleRc.top,m_RTitleRc.Width(),
  661. m_RTitleRc.Height(),&memDC,0,0,x,y,SRCCOPY);
  662. DeleteObject( memDC.SelectObject(OldObj));
  663. LeftLine.Detach();
  664. }
  665. //绘制中间标题
  666. if(Flags & FMIDTITLE)
  667. {
  668. DeleteObject(LeftLine);
  669. LeftLine.LoadBitmap(IDB_MIDTITLE);
  670. //获取位图大小
  671. LeftLine.GetObject(sizeof(bitinfo),&bitinfo);
  672. OldObj = memDC.SelectObject(&LeftLine);
  673. x = bitinfo.bmiHeader.biWidth;
  674. y = bitinfo.bmiHeader.biHeight;
  675. m_TitleDrawHeight = (m_CaptionHeight+4 > y) ? m_CaptionHeight+4 : y;
  676. m_MTitleRc.CopyRect(CRect(m_LTitleRc.right,0,m_RTitleRc.left,m_TitleDrawHeight));
  677. WindowDC.StretchBlt(m_MTitleRc.left,m_MTitleRc.top,m_MTitleRc.Width(),
  678. m_MTitleRc.Height(),&memDC,0,0,x,y,SRCCOPY);
  679. LeftLine.Detach();
  680. memDC.SelectObject(OldObj);
  681. }
  682. //绘制右边框
  683. if(Flags & FRIGHTBAR)
  684. {
  685. DeleteObject(LeftLine);
  686. LeftLine.LoadBitmap(IDB_RIGHTBAR);
  687. //获取位图大小
  688. LeftLine.GetObject(sizeof(bitinfo),&bitinfo);
  689. OldObj = memDC.SelectObject(&LeftLine);
  690. x = bitinfo.bmiHeader.biWidth;
  691. y = bitinfo.bmiHeader.biHeight;
  692. rLineWidth = m_FrameWidth + m_BorderWidth;
  693. rLineWidth = rLineWidth>x? rLineWidth:x;
  694. WindowDC.StretchBlt(m_RTitleRc.right-rLineWidth,m_TitleDrawHeight,rLineWidth,
  695. FactRC.Height()-m_TitleDrawHeight,&memDC,0,0,x,y,SRCCOPY);
  696. memDC.SelectObject(OldObj);
  697. LeftLine.Detach();
  698. }
  699. //绘制底边框
  700. if(Flags & FBOTTOMBAR)
  701. {
  702. DeleteObject(LeftLine);
  703. LeftLine.LoadBitmap(IDB_BOTTOMBAR);
  704. //获取位图大小
  705. LeftLine.GetObject(sizeof(bitinfo),&bitinfo);
  706. OldObj = memDC.SelectObject(&LeftLine);
  707. x = bitinfo.bmiHeader.biWidth;
  708. y = bitinfo.bmiHeader.biHeight;
  709. bLineHeight = m_BorderHeight + m_FrameHeight;
  710. bLineHeight = bLineHeight>y? bLineHeight:y;
  711. WindowDC.StretchBlt(leftlinewidth,FactRC.Height()-bLineHeight,m_RTitleRc.right
  712. -rLineWidth-leftlinewidth, bLineHeight,&memDC,0,0,x,y,SRCCOPY);
  713. memDC.SelectObject(OldObj);
  714. LeftLine.Detach();
  715. }
  716. //绘制底边框
  717. CPoint pos(30,1);
  718. m_MinRect.CopyRect(CRect(m_RTitleRc.left+pos.x,(m_TitleDrawHeight+2*m_BorderHeight
  719. -m_ButtonHeight)/2+pos.y,m_ButtonWidth,m_ButtonHeight));
  720. pos.x = 55; 
  721. m_MaxRect.CopyRect(CRect(m_RTitleRc.left+pos.x,(m_TitleDrawHeight+2*m_BorderHeight 
  722. -m_ButtonHeight)/2+pos.y,m_ButtonWidth,m_ButtonHeight));
  723. pos.x = 80;
  724. m_CloseRect.CopyRect(CRect(m_RTitleRc.left+pos.x,(m_TitleDrawHeight+2*m_BorderHeight
  725. -m_ButtonHeight)/2+pos.y,m_ButtonWidth,m_ButtonHeight));
  726. //绘制最小化按钮
  727. if(Flags & FMINBUTTON)
  728. {
  729. DeleteObject(LeftLine);
  730. LeftLine.LoadBitmap(IDB_MINBT);
  731. //获取位图大小
  732. LeftLine.GetObject(sizeof(bitinfo),&bitinfo);
  733. OldObj = memDC.SelectObject(&LeftLine);
  734. x = bitinfo.bmiHeader.biWidth;
  735. y = bitinfo.bmiHeader.biHeight;
  736. WindowDC.StretchBlt(m_MinRect.left,m_MinRect.top,m_MinRect.right,
  737. m_MinRect.bottom,&memDC,0,0,x,y,SRCCOPY);
  738. memDC.SelectObject(OldObj);
  739. LeftLine.Detach();
  740. }
  741. //绘制最大化按钮
  742. if ( Flags & FMAXBUTTON)
  743. {
  744. DeleteObject(LeftLine);
  745. LeftLine.LoadBitmap(IDB_MAXBT);
  746. //获取位图大小
  747. LeftLine.GetObject(sizeof(bitinfo),&bitinfo);
  748. OldObj =  memDC.SelectObject(&LeftLine);
  749. x = bitinfo.bmiHeader.biWidth;
  750. y = bitinfo.bmiHeader.biHeight;
  751. WindowDC.StretchBlt(m_MaxRect.left,m_MaxRect.top,m_MaxRect.right,
  752. m_MaxRect.bottom,&memDC,0,0,x,y,SRCCOPY);
  753. memDC.SelectObject(OldObj);
  754. LeftLine.Detach();
  755. }
  756. //绘制关闭按钮
  757. if(Flags & FCLOSEBUTTON)
  758. {
  759. DeleteObject(LeftLine);
  760. LeftLine.LoadBitmap(IDB_CLOSEBT);
  761. //获取位图大小
  762. LeftLine.GetObject(sizeof(bitinfo),&bitinfo);
  763. OldObj = memDC.SelectObject(&LeftLine);
  764. x = bitinfo.bmiHeader.biWidth;
  765. y = bitinfo.bmiHeader.biHeight;
  766. WindowDC.StretchBlt(m_CloseRect.left,m_CloseRect.top,m_CloseRect.right,
  767. m_CloseRect.bottom,&memDC,0,0,x,y,SRCCOPY);
  768. memDC.SelectObject(OldObj);
  769. LeftLine.Detach();
  770. }
  771. LeftLine.DeleteObject();
  772. memDC.DeleteDC();
  773. DrawCaption();
  774. }
  775. void CCaptureDlg::DrawCaption()
  776. {
  777. if(!m_Caption.IsEmpty())
  778. {
  779. CDC* pDC = GetWindowDC();
  780. pDC->SetBkMode(TRANSPARENT);
  781. pDC->SetTextColor(m_CapitonColor);
  782. pDC->SetTextAlign(TA_CENTER);
  783. CRect rect;
  784. GetClientRect(rect);
  785. pDC->SelectObject(&m_CaptionFont);
  786. pDC->TextOut(rect.Width()/2, m_CaptionHeight/3 ,m_Caption);
  787. ReleaseDC(pDC);
  788. }
  789. }
  790. void CCaptureDlg::OnNcMouseMove(UINT nHitTest, CPoint point) 
  791. {
  792. // TODO: Add your message handler code here and/or call default
  793. CRect tempMin,tempMax,tempClose,ClientRect;
  794. CWindowDC WindowDC (this);
  795. CDC memDC;
  796. memDC.CreateCompatibleDC(&WindowDC);
  797. BITMAPINFO bInfo;
  798. CBitmap LeftLine;
  799. int x,y;
  800. GetWindowRect(ClientRect);
  801. tempMin.CopyRect(CRect(m_MinRect.left+ ClientRect.left,ClientRect.top
  802. +m_MinRect.top,m_MinRect.right+m_MinRect.left+ ClientRect.left,
  803. m_MinRect.bottom+m_MinRect.top+ClientRect.top));
  804. tempMax.CopyRect(CRect(m_MaxRect.left+ ClientRect.left,ClientRect.top
  805. +m_MaxRect.top,m_MaxRect.right+m_MaxRect.left+ ClientRect.left,
  806. m_MaxRect.bottom+m_MaxRect.top+ClientRect.top));
  807. tempClose.CopyRect(CRect(m_CloseRect.left+ ClientRect.left,ClientRect.top
  808. +m_CloseRect.top,m_CloseRect.right+m_CloseRect.left+ ClientRect.left,
  809. m_CloseRect.bottom+m_CloseRect.top+ClientRect.top));
  810. if(tempMin.PtInRect(point)) //鼠标在最小化按钮上移动时,更改按钮显示的位图
  811. {
  812. if(m_ButtonState != bsMin)
  813. {
  814. LeftLine.LoadBitmap(IDB_MINHOTBT);
  815. LeftLine.GetObject(sizeof(bInfo),&bInfo);
  816. x = bInfo.bmiHeader.biWidth;
  817. y = bInfo.bmiHeader.biHeight;
  818. memDC.SelectObject(&LeftLine);
  819. WindowDC.StretchBlt(m_MinRect.left,m_MinRect.top,m_MinRect.right,
  820. m_MinRect.bottom,&memDC,0,0,x,y,SRCCOPY);
  821. m_IsDrawForm = FALSE;
  822. m_ButtonState = bsMin;
  823. LeftLine.Detach();
  824. }
  825. }
  826. else if(tempMax.PtInRect(point))
  827. {
  828. if(m_ButtonState!=bsMax && m_ButtonState!=bsRes)
  829. {
  830. LeftLine.LoadBitmap(IDB_MAXHOTBT);
  831. LeftLine.GetObject(sizeof(bInfo),&bInfo);
  832. x = bInfo.bmiHeader.biWidth;
  833. y = bInfo.bmiHeader.biHeight;
  834. memDC.SelectObject(&LeftLine);
  835. WindowDC.StretchBlt(m_MaxRect.left,m_MaxRect.top,m_MaxRect.right,
  836. m_MaxRect.bottom,&memDC,0,0,x,y,SRCCOPY);
  837. m_IsDrawForm = FALSE;
  838. if (m_IsMax)
  839. {
  840. m_ButtonState = bsMax;
  841. }
  842. else
  843. {
  844. m_ButtonState = bsRes;
  845. }
  846. LeftLine.Detach();
  847. }
  848. }
  849. else if(tempClose.PtInRect(point))
  850. {
  851. if(m_ButtonState != bsClose)
  852. {
  853. LeftLine.LoadBitmap(IDB_CLOSEHOTBT);
  854. LeftLine.GetObject(sizeof(bInfo),&bInfo);
  855. x = bInfo.bmiHeader.biWidth;
  856. y = bInfo.bmiHeader.biHeight;
  857. memDC.SelectObject(&LeftLine);
  858. WindowDC.StretchBlt(m_CloseRect.left,m_CloseRect.top,m_CloseRect.right,
  859. m_CloseRect.bottom,&memDC,0,0,x,y,SRCCOPY);
  860. m_IsDrawForm = FALSE;
  861. m_ButtonState = bsClose;
  862. LeftLine.Detach();
  863. }
  864. }
  865. else
  866. {
  867. if(m_IsDrawForm == FALSE)
  868. {
  869. if(m_ButtonState == bsMin)
  870. DrawDialog( FMINBUTTON);
  871. else if(m_ButtonState == bsClose)
  872. DrawDialog( FCLOSEBUTTON);
  873. else if(m_ButtonState == bsMax || m_ButtonState==bsRes)
  874. DrawDialog( FMAXBUTTON);
  875. }
  876. m_ButtonState = bsNone;
  877. }
  878. LeftLine.DeleteObject();
  879. ReleaseDC(&memDC);
  880. CDialog::OnNcMouseMove(nHitTest, point);
  881. }
  882. void CCaptureDlg::OnMouseMove(UINT nFlags, CPoint point) 
  883. {
  884. // TODO: Add your message handler code here and/or call default
  885. if(m_ButtonState != bsNone)
  886. {
  887. if(m_ButtonState == bsMin)
  888. DrawDialog(FMINBUTTON);
  889. else if(m_ButtonState == bsClose)
  890. DrawDialog(FCLOSEBUTTON);
  891. else if(m_ButtonState==bsMax || m_ButtonState==bsRes)
  892. DrawDialog(FMAXBUTTON);
  893. m_ButtonState = bsNone;
  894. }
  895. CDialog::OnMouseMove(nFlags, point);
  896. }
  897. void CCaptureDlg::OnNcLButtonDown(UINT nHitTest, CPoint point) 
  898. {
  899. // TODO: Add your message handler code here and/or call default
  900. switch(m_ButtonState)
  901. {
  902. case bsClose: //关闭窗口
  903. {
  904. OnCancel();
  905. }
  906. break;
  907. case bsMin: 
  908. {
  909. ShowWindow(SW_SHOWMINIMIZED);
  910. }
  911. break;
  912. case bsMax:
  913. {
  914. m_ButtonState = bsMax;
  915. ShowWindow(SW_SHOWMAXIMIZED);
  916. m_IsMax = FALSE;
  917. }
  918. break;
  919. case bsRes:
  920. {
  921. ShowWindow(SW_RESTORE);
  922. m_IsMax = TRUE;
  923. }
  924. break;
  925. }
  926. CDialog::OnNcLButtonDown(nHitTest, point);
  927. }
  928. BOOL CCaptureDlg::OnNcActivate(BOOL bActive) 
  929. {
  930. // TODO: Add your message handler code here and/or call default
  931. OnPaint() ;
  932. return CDialog::OnNcActivate(bActive);
  933. }
  934. void CCaptureDlg::MoveCapture(UINT num)
  935. {
  936. VARIANT vt;
  937. SAFEARRAY* pSafe;
  938. SAFEARRAYBOUND band;
  939. band.cElements = m_Len;
  940. band.lLbound   = 0;
  941. pSafe = SafeArrayCreate(VT_UI1,1,&band);
  942. for(long i=0;i<m_Len;i++)
  943. {
  944. SafeArrayPutElement(pSafe,&i,(void*)&m_pData[num][i]);
  945. }
  946. vt.vt     = VT_ARRAY |VT_UI1;
  947. vt.parray = pSafe;
  948. m_Com.SetOutput((COleVariant)vt);
  949. }
  950. //向上移动
  951. void CCaptureDlg::OnUp()
  952. {
  953. MoveCapture(0);
  954. }
  955. //停止移动
  956. void CCaptureDlg::OnReset()
  957. {
  958. MoveCapture(12);
  959. }
  960. //向下移动
  961. void CCaptureDlg::OnDown()
  962. {
  963. MoveCapture(1);
  964. }
  965. //向左移动
  966. void CCaptureDlg::OnLeft()
  967. {
  968. MoveCapture(2);
  969. }
  970. //向右移动
  971. void CCaptureDlg::OnRight()
  972. {
  973. MoveCapture(3);
  974. }
  975. //增加聚焦
  976. void CCaptureDlg::OnInFoci()
  977. {
  978. MoveCapture(5);
  979. }
  980. //减小聚焦
  981. void CCaptureDlg::OnReFoci()
  982. {
  983. MoveCapture(4);
  984. }
  985. //对焦增
  986. void CCaptureDlg::OnInLen()
  987. {
  988. MoveCapture(7);
  989. }
  990. //对焦减
  991. void CCaptureDlg::OnReLen()
  992. {
  993. MoveCapture(6);
  994. }
  995. //光圈减
  996. void CCaptureDlg::OnReAperture()
  997. {
  998. MoveCapture(8);
  999. }
  1000. //光圈增
  1001. void CCaptureDlg::OnInAperture()
  1002. {
  1003. MoveCapture(9);
  1004. }
  1005. //雨刷减
  1006. void CCaptureDlg::OnReBrush()
  1007. {
  1008. MoveCapture(10);
  1009. }
  1010. //雨刷增
  1011. void CCaptureDlg::OnInBrush()
  1012. {
  1013. MoveCapture(11);
  1014. }
  1015. void CCaptureDlg::OnControl() 
  1016. {
  1017. // TODO: Add your control notification handler code here
  1018. CControlForm dlg;
  1019. dlg.m_UserName = m_UserName;
  1020. dlg.m_LogPath  = m_LogPath;
  1021. dlg.DoModal();
  1022. Invalidate();
  1023. }
  1024. DWORD WINAPI ThreadProc(LPVOID lpParameter )
  1025. {
  1026. CCaptureDlg* pDlg = (CCaptureDlg*)lpParameter;
  1027. while (true) 
  1028. {
  1029. switch(pDlg->m_Num)
  1030. {
  1031. case 0:
  1032. //向上
  1033. pDlg->MoveCapture(0);
  1034. Sleep(2000);
  1035. //向左
  1036. pDlg->MoveCapture(2);
  1037. Sleep(22000);
  1038. //向下
  1039. pDlg->MoveCapture(1);
  1040. Sleep(2000);
  1041. //向右
  1042. pDlg->MoveCapture(3);
  1043. Sleep(22000);
  1044. //向下
  1045. pDlg->MoveCapture(1);
  1046. Sleep(2000);
  1047. //向左
  1048. pDlg->MoveCapture(2);
  1049. Sleep(22000);
  1050. //向上
  1051. pDlg->MoveCapture(0);
  1052. Sleep(2000);
  1053. //向右
  1054. pDlg->MoveCapture(3);
  1055. Sleep(22000);
  1056. break;
  1057. case 1:
  1058. //向左
  1059. pDlg->MoveCapture(2);
  1060. Sleep(22000);
  1061. //向右
  1062. pDlg->MoveCapture(3);
  1063. Sleep(22000);
  1064. break;
  1065. case 2:
  1066. //向上
  1067. pDlg->MoveCapture(0);
  1068. Sleep(2000);
  1069. //向下
  1070. pDlg->MoveCapture(1);
  1071. Sleep(2000);
  1072. break;
  1073. }
  1074. }
  1075. return 0;
  1076. }
  1077. void CCaptureDlg::OnAutomatism() 
  1078. {
  1079. // TODO: Add your control notification handler code here
  1080. CAutodlg dlg;
  1081. dlg.m_UserName = m_UserName;
  1082. dlg.m_LogPath  = m_LogPath;
  1083. if(dlg.DoModal()==IDOK)
  1084. {
  1085. DWORD threadID;
  1086. m_hThread = ::CreateThread(NULL,0,ThreadProc,(LPVOID)this,0,&threadID);
  1087. m_Num = dlg.m_Num;
  1088. m_Time = dlg.m_Time;
  1089. if(m_Time)
  1090. {
  1091. m_StopTime = dlg.stoptime;
  1092. }
  1093. }
  1094. Invalidate();
  1095. }
  1096. void CCaptureDlg::OnStop() 
  1097. {
  1098. // TODO: Add your control notification handler code here
  1099. //停止运动
  1100. MoveCapture(12);
  1101. ::TerminateThread(m_hThread,0);
  1102. //停止监控
  1103. VCAStopVideoCapture(0);
  1104. }
  1105. void CCaptureDlg::OnKinescope() 
  1106. {
  1107. // TODO: Add your control notification handler code here
  1108. if(!m_Kinescope)
  1109. {
  1110. if(CPreView::m_CurIndex != -1)
  1111. {
  1112. CFileDialog fDlg(FALSE,"avi","avi_001",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"AVI|*.avi",this);
  1113. if (fDlg.DoModal()==IDOK)
  1114. {
  1115. m_Kinescope = TRUE;
  1116. CString file = fDlg.GetPathName();
  1117. VCASetKeyFrmInterval(CPreView::m_CurIndex,250);
  1118. VCASetBitRate(CPreView::m_CurIndex,256);
  1119. VCASetVidCapFrameRate(CPreView::m_CurIndex,25);
  1120. VCASetVidCapSize(CPreView::m_CurIndex,320,240);
  1121. VCASetXVIDQuality(CPreView::m_CurIndex,10,3);
  1122. VCASetXVIDCompressMode(CPreView::m_CurIndex,XVID_VBR_MODE);
  1123. BOOL ret = VCAStartVideoCapture(CPreView::m_CurIndex,CAP_ORIGIN_MPEG4_STREAM,
  1124. MPEG4_AVIFILE_CALLBACK ,file);
  1125. GetDlgItem(IDC_KINESCOPE)->SetWindowText("停止录像");
  1126. }
  1127. }
  1128. m_LogTime = CTime::GetCurrentTime();
  1129. CString strText;
  1130. strText.Format("%st%st录像rn",m_UserName,
  1131. m_LogTime.Format("%y-%m-%d %H:%M:%S"));
  1132. CFile file;
  1133. file.Open(m_LogPath,CFile::modeWrite);
  1134. file.SeekToEnd();
  1135. file.Write(strText,strText.GetLength());
  1136. file.Close();
  1137. }
  1138. else
  1139. {
  1140. m_Kinescope = FALSE;
  1141. GetDlgItem(IDC_KINESCOPE)->SetWindowText("录像");
  1142. VCAStopVideoCapture(CPreView::m_CurIndex);
  1143. }
  1144. }
  1145. void CCaptureDlg::OnPlay() 
  1146. {
  1147. // TODO: Add your control notification handler code here
  1148. CPlaydlg dlg;
  1149. dlg.m_UserName = m_UserName;
  1150. dlg.m_LogPath  = m_LogPath;
  1151. dlg.DoModal();
  1152. Invalidate();
  1153. }
  1154. void CCaptureDlg::OnManage() 
  1155. {
  1156. // TODO: Add your control notification handler code here
  1157. CManagedlg dlg;
  1158. dlg.m_UserName = m_UserName;
  1159. dlg.m_LogPath  = m_LogPath;
  1160. dlg.m_PathText = m_PathText;
  1161. dlg.DoModal();
  1162. Invalidate();
  1163. }