VISDlg.cpp
上传用户:sdgangtie
上传日期:2020-03-07
资源大小:7324k
文件大小:17k
开发平台:

Visual C++

  1. // VISDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "VIS.h"
  5. #include "VISDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #endif
  9. // CAboutDlg dialog used for App About
  10. class CAboutDlg : public CDialog
  11. {
  12. public:
  13. CAboutDlg();
  14. // Dialog Data
  15. enum { IDD = IDD_ABOUTBOX };
  16. protected:
  17. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  18. // Implementation
  19. protected:
  20. // Generated message map functions
  21. //{{AFX_MSG(CAboutDlg)
  22. virtual BOOL OnInitDialog();
  23. //}}AFX_MSG
  24. DECLARE_MESSAGE_MAP()
  25. private:
  26. CButtonST m_Logo;
  27. CButtonST m_Face;
  28. public:
  29. afx_msg void OnBnClickedOk();
  30. };
  31. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  32. {
  33. }
  34. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CDialog::DoDataExchange(pDX);
  37. DDX_Control(pDX, IDC_LOGO, m_Logo);
  38. DDX_Control(pDX, IDC_FACE, m_Face);
  39. }
  40. BOOL CAboutDlg::OnInitDialog() 
  41. {
  42. CDialog::OnInitDialog();
  43. // Logo button
  44. m_Logo.m_bShowDisabledBitmap = FALSE;
  45. m_Logo.SetBitmaps(IDB_LOGO, RGB(255, 255, 255));
  46. // Face button
  47. m_Face.m_bShowDisabledBitmap = FALSE;
  48. m_Face.SetBitmaps(IDB_FACE, RGB(0, 255, 0));
  49. // Write class version
  50. CString sVersion;
  51. sVersion.Format(_T("System VIS Version %s"), CButtonST::GetVersionC());
  52. GetDlgItem(IDC_VERSION)->SetWindowText(sVersion);
  53. return TRUE;
  54. } // End of OnInitDialog
  55. void CAboutDlg::OnBnClickedOk()
  56. {
  57. OnOK();
  58. }
  59. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  60. ON_BN_CLICKED(IDOK, &CAboutDlg::OnBnClickedOk)
  61. END_MESSAGE_MAP()
  62. // CVISDlg dialog
  63. CVISDlg::CVISDlg(CWnd* pParent /*=NULL*/)
  64. : CDialog(CVISDlg::IDD, pParent)
  65. , m_TimeValue(_T(""))
  66. {
  67. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  68. }
  69. void CVISDlg::DoDataExchange(CDataExchange* pDX)
  70. {
  71. CDialog::DoDataExchange(pDX);
  72. DDX_Control(pDX, IDC_LIST, m_ListBoxCtrl);
  73. DDX_Control(pDX, IDC_ADD, m_Add);
  74. DDX_Control(pDX, IDC_DELETE, m_Del);
  75. DDX_Control(pDX, IDC_MODE, m_Mod);
  76. DDX_Control(pDX, IDC_SLIDER, m_SliderCtrl);
  77. DDX_Text(pDX, IDC_TIME, m_TimeValue);
  78. DDX_Control(pDX, IDC_OPEN, m_Open);
  79. DDX_Control(pDX, IDC_RUN, m_Run);
  80. DDX_Control(pDX, IDC_STOP, m_Stop);
  81. DDX_Control(pDX, IDC_SETTING, m_Setting);
  82. }
  83. BEGIN_MESSAGE_MAP(CVISDlg, CDialog)
  84. ON_WM_SYSCOMMAND()
  85. ON_WM_PAINT()
  86. ON_WM_QUERYDRAGICON()
  87. ON_WM_RBUTTONUP()
  88. ON_WM_TIMER()
  89. ON_WM_SIZE()
  90. //}}AFX_MSG_MAP
  91. ON_BN_CLICKED(IDC_ADD, &CVISDlg::OnBnClickedAdd)
  92. ON_BN_CLICKED(IDC_DELETE, &CVISDlg::OnBnClickedDelete)
  93. ON_COMMAND(ID_RUNSTYLE_NORMALPLAY, &CVISDlg::OnStyleNormal)
  94. ON_COMMAND(ID_RUNSTYLE_FGTEMPPLAY, &CVISDlg::OnStyleTemped)
  95. ON_COMMAND(ID_RUNSTYLE_RESULTPLAY, &CVISDlg::OnStyleResult)
  96. ON_COMMAND(IDM_FILE_OPEN, &CVISDlg::OnBnClickedOpen)
  97. ON_COMMAND(IDM_FILE_ADD, &CVISDlg::OnBnClickedAdd)
  98. ON_COMMAND(IDM_RUNSTYLE_NORMALPLAY, &CVISDlg::OnStyleNormal)
  99. ON_COMMAND(IDM_RUNSTYLE_FGTEMPPLAY, &CVISDlg::OnStyleTemped)
  100. ON_COMMAND(IDM_RUNSTYLE_RESULTPLAY, &CVISDlg::OnStyleResult)
  101. ON_COMMAND(ID_RMENU_SETTING, &CVISDlg::OnBnClickedSetting)
  102. ON_COMMAND(ID_EXIT, &CVISDlg::OnExit)
  103. ON_BN_CLICKED(IDC_OPEN, &CVISDlg::OnBnClickedOpen)
  104. ON_BN_CLICKED(IDC_RUN, &CVISDlg::OnBnClickedRun)
  105. ON_BN_CLICKED(IDC_STOP, &CVISDlg::OnBnClickedStop)
  106. ON_LBN_DBLCLK(IDC_LIST, &CVISDlg::OnLbnDblclkList)
  107. ON_LBN_SELCHANGE(IDC_LIST, &CVISDlg::OnLbnSelchangeList)
  108. ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER, &CVISDlg::OnNMReleasedcaptureSlider)
  109. ON_BN_CLICKED(IDC_SETTING, &CVISDlg::OnBnClickedSetting)
  110. END_MESSAGE_MAP()
  111. // CVISDlg message handlers
  112. BOOL CVISDlg::OnInitDialog()
  113. {
  114. CDialog::OnInitDialog();
  115. // Add "About..." menu item to system menu.
  116. // IDM_ABOUTBOX must be in the system command range.
  117. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  118. ASSERT(IDM_ABOUTBOX < 0xF000);
  119. CMenu* pSysMenu = GetSystemMenu(FALSE);
  120. if (pSysMenu != NULL)
  121. {
  122. CString strAboutMenu;
  123. strAboutMenu.LoadString(IDS_ABOUTBOX);
  124. if (!strAboutMenu.IsEmpty())
  125. {
  126. pSysMenu->AppendMenu(MF_SEPARATOR);
  127. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  128. }
  129. }
  130. // Set the icon for this dialog.  The framework does this automatically
  131. //  when the application's main window is not a dialog
  132. SetIcon(m_hIcon, TRUE); // Set big icon
  133. SetIcon(m_hIcon, FALSE); // Set small icon
  134. // TODO: Add extra initialization here
  135. { // 初始化状态栏
  136. m_StatusBar = new CStatusBarCtrl;
  137. RECT m_Rect;
  138. GetClientRect(&m_Rect);
  139. m_Rect.top = m_Rect.bottom - 20;
  140. m_StatusBar->Create(WS_VISIBLE|CBRS_BOTTOM,m_Rect,this,3);
  141. int nParts[2] = {100,-1};
  142. m_StatusBar->SetParts(2,nParts);
  143. m_StatusBar->SetText(TEXT(" Ready"),0,0);
  144. m_StatusBar->SetText(TEXT(" "),1,0);
  145. }
  146. { // 初始化按钮
  147. short shBtnColor = 0;
  148. m_Add.SetIcon(IDI_ICON_ADD, (int)BTNST_AUTO_GRAY);
  149. m_Add.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
  150. m_Add.SetTooltipText(_T("Add File"));
  151. m_Del.SetIcon(IDI_ICON_DEL, (int)BTNST_AUTO_GRAY);
  152. m_Del.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
  153. m_Del.SetTooltipText(_T("Delete File"));
  154. m_Mod.SetIcon(IDI_ICON_MOD, (int)BTNST_AUTO_GRAY);
  155. m_Mod.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
  156. m_Mod.SetTooltipText(_T("Play Mode"));
  157. m_Mod.SetMenu(IDR_MENU, m_hWnd);
  158. shBtnColor = 30;
  159. m_Setting.SetIcon(IDI_ICON_SET, (int)BTNST_AUTO_GRAY);
  160. m_Setting.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
  161. m_Setting.SetTooltipText(_T("Setting Paramters"));
  162. //  m_Open.SetIcon(IDI_ICON_OPEN2, IDI_ICON_OPEN1);
  163. //  m_Open.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
  164. // 
  165. //  m_Run.SetIcon(IDI_ICON_PLAY2, IDI_ICON_PLAY1);
  166. //  m_Run.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
  167. // 
  168. //  m_Stop.SetIcon(IDI_ICON_STOP, IDI_ICON_STOP);
  169. //  m_Stop.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
  170. }
  171. VERIFY(menu.LoadMenu(IDR_MENU_MAIN));
  172. m_FilePathList.RemoveAll();
  173. m_FilePathIndex = 0;
  174. m_RunStyle = 0;
  175. m_SliderCtrl.SetRange(0,100,TRUE);
  176. m_pImage = cvLoadImage("default.bmp");
  177. SetTimer(1,33,NULL);
  178. return TRUE;  // return TRUE  unless you set the focus to a control
  179. }
  180. void CVISDlg::OnSysCommand(UINT nID, LPARAM lParam)
  181. {
  182. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  183. {
  184. CAboutDlg dlgAbout;
  185. dlgAbout.DoModal();
  186. }
  187. else
  188. {
  189. CDialog::OnSysCommand(nID, lParam);
  190. }
  191. }
  192. // If you add a minimize button to your dialog, you will need the code below
  193. //  to draw the icon.  For MFC applications using the document/view model,
  194. //  this is automatically done for you by the framework.
  195. void CVISDlg::OnPaint()
  196. {
  197. if (IsIconic())
  198. {
  199. CPaintDC dc(this); // device context for painting
  200. SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
  201. // Center icon in client rectangle
  202. int cxIcon = GetSystemMetrics(SM_CXICON);
  203. int cyIcon = GetSystemMetrics(SM_CYICON);
  204. CRect rect;
  205. GetClientRect(&rect);
  206. int x = (rect.Width() - cxIcon + 1) / 2;
  207. int y = (rect.Height() - cyIcon + 1) / 2;
  208. // Draw the icon
  209. dc.DrawIcon(x, y, m_hIcon);
  210. }
  211. else
  212. {
  213. CDialog::OnPaint();
  214. }
  215. }
  216. // The system calls this function to obtain the cursor to display while the user drags
  217. //  the minimized window.
  218. HCURSOR CVISDlg::OnQueryDragIcon()
  219. {
  220. return static_cast<HCURSOR>(m_hIcon);
  221. }
  222. void CVISDlg::OnBnClickedAdd()
  223. {
  224. CString Filter = TEXT("视频文件(*.avi)|*avi|所有文件(*.*)|*.*||");
  225. CFileDialog Dlg(TRUE,NULL,NULL,OFN_ALLOWMULTISELECT|OFN_ENABLESIZING,Filter,this);
  226. if(Dlg.DoModal()==IDOK)
  227. {
  228. POSITION Pos = Dlg.GetStartPosition();
  229. while (Pos)
  230. {
  231. CString next = Dlg.GetNextPathName(Pos);
  232. if(!m_FilePathList.Find(next))
  233. {
  234. CString filename = next.Right(next.GetLength()-next.ReverseFind('\')-1);
  235. m_ListBoxCtrl.InsertString(m_FilePathIndex++,filename);
  236. m_FilePathList.AddTail(next);
  237. }
  238. }
  239. }
  240. }
  241. void CVISDlg::OnBnClickedDelete()
  242. {
  243. for (int i = m_ListBoxCtrl.GetCount()-1; i >= 0; i--)
  244. {
  245. if (m_ListBoxCtrl.GetSel(i))
  246. {
  247. if (m_FilePath == m_FilePathList.GetAt(m_FilePathList.FindIndex(i)))
  248. {
  249. m_pRunTrack.Stop();
  250. }
  251. m_FilePathList.RemoveAt(m_FilePathList.FindIndex(i));
  252. m_ListBoxCtrl.DeleteString(i);
  253. m_FilePathIndex--;
  254. }
  255. }
  256. }
  257. void CVISDlg::OnStyleNormal()
  258. {
  259. m_Mod.m_menuPopup.GetSubMenu(0)->CheckMenuItem(ID_RUNSTYLE_NORMALPLAY,MF_BYCOMMAND|MF_CHECKED);
  260. m_Mod.m_menuPopup.GetSubMenu(0)->CheckMenuItem(ID_RUNSTYLE_FGTEMPPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  261. m_Mod.m_menuPopup.GetSubMenu(0)->CheckMenuItem(ID_RUNSTYLE_RESULTPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  262. menu.GetSubMenu(0)->CheckMenuItem(IDM_RUNSTYLE_NORMALPLAY,MF_BYCOMMAND|MF_CHECKED);
  263. menu.GetSubMenu(0)->CheckMenuItem(IDM_RUNSTYLE_FGTEMPPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  264. menu.GetSubMenu(0)->CheckMenuItem(IDM_RUNSTYLE_RESULTPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  265. m_RunStyle = 0;
  266. m_Add.SetTooltipText(_T("Add File"));
  267. }
  268. void CVISDlg::OnStyleTemped()
  269. {
  270. m_Mod.m_menuPopup.GetSubMenu(0)->CheckMenuItem(ID_RUNSTYLE_NORMALPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  271. m_Mod.m_menuPopup.GetSubMenu(0)->CheckMenuItem(ID_RUNSTYLE_FGTEMPPLAY,MF_BYCOMMAND|MF_CHECKED);
  272. m_Mod.m_menuPopup.GetSubMenu(0)->CheckMenuItem(ID_RUNSTYLE_RESULTPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  273. menu.GetSubMenu(0)->CheckMenuItem(IDM_RUNSTYLE_NORMALPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  274. menu.GetSubMenu(0)->CheckMenuItem(IDM_RUNSTYLE_FGTEMPPLAY,MF_BYCOMMAND|MF_CHECKED);
  275. menu.GetSubMenu(0)->CheckMenuItem(IDM_RUNSTYLE_RESULTPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  276. m_RunStyle = 1;
  277. m_Del.SetTooltipText(_T("Delete File"));
  278. }
  279. void CVISDlg::OnStyleResult()
  280. {
  281. m_Mod.m_menuPopup.GetSubMenu(0)->CheckMenuItem(ID_RUNSTYLE_NORMALPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  282. m_Mod.m_menuPopup.GetSubMenu(0)->CheckMenuItem(ID_RUNSTYLE_FGTEMPPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  283. m_Mod.m_menuPopup.GetSubMenu(0)->CheckMenuItem(ID_RUNSTYLE_RESULTPLAY,MF_BYCOMMAND|MF_CHECKED);
  284. menu.GetSubMenu(0)->CheckMenuItem(IDM_RUNSTYLE_NORMALPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  285. menu.GetSubMenu(0)->CheckMenuItem(IDM_RUNSTYLE_FGTEMPPLAY,MF_BYCOMMAND|MF_UNCHECKED);
  286. menu.GetSubMenu(0)->CheckMenuItem(IDM_RUNSTYLE_RESULTPLAY,MF_BYCOMMAND|MF_CHECKED);
  287. m_RunStyle = 2;
  288. m_Mod.SetTooltipText(_T("Play Mode"));
  289. }
  290. void CVISDlg::OnBnClickedOpen()
  291. {
  292. int index = m_ListBoxCtrl.GetCurSel();
  293. CString Filter = TEXT("视频文件(*.avi)|*avi|所有文件(*.*)|*.*||");
  294. CFileDialog Dlg(TRUE,NULL,NULL,NULL,Filter,this);
  295. if(Dlg.DoModal()==IDOK)
  296. {
  297. CString path = Dlg.GetPathName();
  298. if(!m_FilePathList.Find(path))
  299. {
  300. CString filename = path.Right(path.GetLength()-path.ReverseFind('\')-1);
  301. m_ListBoxCtrl.InsertString(m_FilePathIndex++,filename);
  302. m_FilePathList.AddTail(path);
  303. }
  304. CString filename = path.Right(path.GetLength()-path.ReverseFind('\')-1);
  305. index = m_ListBoxCtrl.FindString(-1,filename);
  306. for (int i = 0; i < m_ListBoxCtrl.GetCount(); i++)
  307. {
  308. if (i == index)
  309. {
  310. m_ListBoxCtrl.SetSel(i,TRUE);
  311. }
  312. else
  313. m_ListBoxCtrl.SetSel(i,FALSE);
  314. }
  315. RedrawWindow();
  316. m_FilePath = path;
  317. USES_CONVERSION;
  318. char *str = T2A(m_FilePath);
  319. GetParamFromDlg();
  320. m_SliderCtrl.SetRange(0,(int)m_pRunTrack.Init(str,m_RunStyle,m_ParamSetDlg));
  321. m_SliderCtrl.EnableWindow(TRUE);
  322. m_pRunTrack.Run();
  323. GetDlgItem(IDC_RUN)->SetWindowText(TEXT("Pause"));
  324. }
  325. m_ListBoxCtrl.SetCurSel(index);
  326. }
  327. void CVISDlg::OnBnClickedRun()
  328. {
  329. if (m_FilePath.IsEmpty())
  330. return;
  331. int state = m_pRunTrack.GetState();
  332. if (state==0)
  333. {
  334. int index;
  335. if ((index = m_ListBoxCtrl.GetCurSel()) >= 0)
  336. {
  337. if (m_pRunTrack.GetState() == 0)
  338. {
  339. m_FilePath = m_FilePathList.GetAt(m_FilePathList.FindIndex(index));
  340. }
  341. }
  342. USES_CONVERSION;
  343. char *str = T2A(m_FilePath);
  344. GetParamFromDlg();
  345. m_SliderCtrl.SetRange(0,(int)m_pRunTrack.Init(str,m_RunStyle,m_ParamSetDlg));
  346. m_SliderCtrl.EnableWindow(TRUE);
  347. m_pRunTrack.Run();
  348. GetDlgItem(IDC_RUN)->SetWindowText(TEXT("Pause"));
  349. }
  350. if (state==1)
  351. {
  352. m_pRunTrack.Pause();
  353. GetDlgItem(IDC_RUN)->SetWindowText(TEXT("Continue"));
  354. m_StatusBar->SetText(TEXT(" Ready"),0,0);
  355. }
  356. if (state==2)
  357. {
  358. m_pRunTrack.Run();
  359. GetDlgItem(IDC_RUN)->SetWindowText(TEXT("Pause"));
  360. }
  361. }
  362. void CVISDlg::OnBnClickedStop()
  363. {
  364. m_pRunTrack.Stop();
  365. m_SliderCtrl.SetPos(m_pRunTrack.GetFrameCount());
  366. GetDlgItem(IDC_RUN)->SetWindowText(TEXT("Run"));
  367. m_StatusBar->SetText(TEXT(" Ready"),0,0);
  368. GetDlgItem(IDC_TIME)->SetWindowText(m_pRunTrack.GetTimeFre());
  369. }
  370. void CVISDlg::OnBnClickedSetting()
  371. {
  372. if (m_ParamDlg.DoModal());
  373. }
  374. void CVISDlg::OnExit()
  375. {
  376. CDialog::OnCancel();
  377. }
  378. void CVISDlg::OnLbnDblclkList()
  379. {
  380. int index;
  381. if ((index = m_ListBoxCtrl.GetCurSel()) >= 0)
  382. {
  383. for (int i = 0; i < m_ListBoxCtrl.GetCount(); i++)
  384. {
  385. if (i == index)
  386. {
  387. m_ListBoxCtrl.SetSel(i,TRUE);
  388. }
  389. else
  390. m_ListBoxCtrl.SetSel(i,FALSE);
  391. }
  392. RedrawWindow();
  393. m_FilePath = m_FilePathList.GetAt(m_FilePathList.FindIndex(index));
  394. USES_CONVERSION;
  395. char *str = T2A(m_FilePath);
  396. GetParamFromDlg();
  397. m_SliderCtrl.SetRange(0,(int)m_pRunTrack.Init(str,m_RunStyle,m_ParamSetDlg));
  398. m_SliderCtrl.EnableWindow(TRUE);
  399. m_pRunTrack.Run();
  400. GetDlgItem(IDC_RUN)->SetWindowText(TEXT("Pause"));
  401. }
  402. }
  403. void CVISDlg::OnLbnSelchangeList()
  404. {
  405. int index;
  406. if ((index = m_ListBoxCtrl.GetCurSel()) >= 0)
  407. {
  408. if (m_pRunTrack.GetState() == 0)
  409. {
  410. m_FilePath = m_FilePathList.GetAt(m_FilePathList.FindIndex(index));
  411. }
  412. }
  413. }
  414. void CVISDlg::OnRButtonUp(UINT nFlags, CPoint point)
  415. {
  416. DWORD dwPos = GetMessagePos(); 
  417. CPoint _point(LOWORD(dwPos), HIWORD(dwPos));
  418. CMenu* popup = menu.GetSubMenu(0);
  419. ASSERT( popup != NULL ); 
  420. popup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, _point.x, _point.y, this);
  421. CDialog::OnRButtonUp(nFlags, point);
  422. }
  423. void CVISDlg::OnNMReleasedcaptureSlider(NMHDR *pNMHDR, LRESULT *pResult)
  424. {
  425. if (m_pRunTrack.GetState() == 2)
  426. {
  427. m_pRunTrack.SetPosition(m_SliderCtrl.GetPos());
  428. m_pRunTrack.Run();
  429. GetDlgItem(IDC_RUN)->SetWindowText(TEXT("Pause"));
  430. }
  431. }
  432. void CVISDlg::GetParamFromDlg()
  433. {
  434. m_ParamSetDlg.m_FG = m_ParamDlg.m_FG;
  435. m_ParamSetDlg.m_BT = m_ParamDlg.m_BT;
  436. m_ParamSetDlg.m_BPP = m_ParamDlg.m_BPP;
  437. m_ParamSetDlg.m_BTA = m_ParamDlg.m_BTA;
  438. m_ParamSetDlg.m_Threshold = m_ParamDlg.m_Threshold;
  439. m_ParamSetDlg.m_WMin = m_ParamDlg.m_WMin;
  440. m_ParamSetDlg.m_WMax = m_ParamDlg.m_WMax;
  441. m_ParamSetDlg.m_HMin = m_ParamDlg.m_HMin;
  442. m_ParamSetDlg.m_HMax = m_ParamDlg.m_HMax;
  443. m_ParamSetDlg.m_Check = m_ParamDlg.m_Check;
  444. //  CString str;
  445. //  str.Format(TEXT("%d,%d,%d,%d"),m_ParamSetDlg.m_FG,m_ParamSetDlg.m_BT,m_ParamSetDlg.m_BPP,m_ParamSetDlg.m_BTA);
  446. //  MessageBox(str);
  447. }
  448. void CVISDlg::DrawFrameToHDC(IplImage* pImage, UINT ID)
  449. {
  450. if (pImage != NULL)
  451. {
  452. CDC *pDC = GetDlgItem(ID)->GetDC();
  453. HDC hDC = pDC->GetSafeHdc();
  454. CRect r;
  455. GetDlgItem(ID)->GetClientRect(&r);
  456. CvvImage img;
  457. img.CopyOf(pImage);
  458. img.DrawToHDC(hDC, &r);
  459. ReleaseDC(pDC);
  460. }
  461. }
  462. void CVISDlg::OnTimer(UINT_PTR nIDEvent)
  463. {
  464. static int Tn = 0;
  465. if (nIDEvent == 1)
  466. {
  467. int state = m_pRunTrack.GetState();
  468. if(state == 0)
  469. {
  470. DrawFrameToHDC(m_pImage, IDC_VIDEO);
  471. GetDlgItem(IDC_TIME)->SetWindowText(TEXT(""));
  472. m_StatusBar->SetText(TEXT(" Ready"),0,0);
  473. GetDlgItem(IDC_RUN)->SetWindowText(TEXT("Run"));
  474. m_SliderCtrl.SetPos(m_pRunTrack.GetFrameCount());
  475. m_SliderCtrl.EnableWindow(FALSE);
  476. }
  477. if(state == 1){
  478. IplImage* pImage = m_pRunTrack.GetNextFrame();
  479. if(pImage)
  480. {
  481. DrawFrameToHDC(pImage, IDC_VIDEO);
  482. m_SliderCtrl.SetPos(m_pRunTrack.GetFrameCount());
  483. if (Tn%40 == 0)
  484. m_StatusBar->SetText(TEXT(" Busy"),0,0);
  485. if (Tn%40 == 10)
  486. m_StatusBar->SetText(TEXT(" Busy."),0,0);
  487. if (Tn%40 == 20)
  488. m_StatusBar->SetText(TEXT(" Busy.."),0,0);
  489. if (Tn%40 == 30)
  490. m_StatusBar->SetText(TEXT(" Busy..."),0,0);
  491. Tn++;
  492. GetDlgItem(IDC_TIME)->SetWindowText(m_pRunTrack.GetTimeFre());
  493. }
  494. }
  495. }
  496. CDialog::OnTimer(nIDEvent);
  497. }
  498. void CVISDlg::OnSize(UINT nType, int cx, int cy)
  499. {
  500. CDialog::OnSize(nType, cx, cy);
  501. if (!IsWindowVisible())
  502. return ;
  503. CRect window;
  504. GetWindowRect( &window );
  505. int width = window.right - window.left - 8;
  506. int height = window.bottom - window.top - 36;
  507. if(width<480) width = 480;
  508. if(height<360) height = 360;
  509. CWnd* pNextWnd = this->GetTopWindow();
  510. pNextWnd->MoveWindow(window.left,window.top,width,height);
  511. for(int i = 1; pNextWnd != NULL; i++ )
  512. {
  513. int ID = pNextWnd->GetDlgCtrlID();
  514. if (ID == IDC_VIDEO) pNextWnd->MoveWindow( 12, 12,  width - 195, height - 145, 1 );
  515. if (ID == IDC_LIST) pNextWnd->MoveWindow( width - 183, 12, 171, height - 145, 1 );
  516. if (ID == IDC_ADD) pNextWnd->MoveWindow( width - 183, height - 133, 57, 25, 1 );
  517. if (ID == IDC_DELETE) pNextWnd->MoveWindow( width - 126, height - 133, 57, 25, 1 );
  518. if (ID == IDC_MODE) pNextWnd->MoveWindow( width -  69, height - 133, 57, 25, 1 );
  519. if (ID == IDC_SLIDER) pNextWnd->MoveWindow( 12,  height - 130, width- 190, 25, 1 );
  520. if (ID == IDC_TIME) pNextWnd->MoveWindow( 25,  height - 64, 64, 26, 1 );
  521. if (ID == IDC_OPEN) pNextWnd->MoveWindow( 125, height - 70, 64, 26, 1 );
  522. if (ID == IDC_RUN) pNextWnd->MoveWindow( 232, height - 70, 64, 26, 1 );
  523. if (ID == IDC_STOP) pNextWnd->MoveWindow( 339, height - 70, 64, 26, 1 );
  524. if (ID == IDC_SETTING) pNextWnd->MoveWindow( 450, height - 75, 96, 36, 1 );
  525. m_StatusBar->MoveWindow(0, height - 12, width, 20, 1);
  526. pNextWnd = pNextWnd->GetNextWindow();
  527. }
  528. }