home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2004 March / PCWELT_3_2004.ISO / pcwsoft / flaskmpeg_078_39_src.z.exe / flaskmpeg / Misc / IEEE1180TestDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  3.5 KB  |  116 lines

  1. /* 
  2.  *  IEEE1180TestDlg.cpp 
  3.  *
  4.  *    Copyright (C) Alberto Vigata - July 2000 - ultraflask@yahoo.com
  5.  *
  6.  *  This file is part of FlasKMPEG, a free MPEG to MPEG/AVI converter
  7.  *    
  8.  *  FlasKMPEG is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2, or (at your option)
  11.  *  any later version.
  12.  *   
  13.  *  FlasKMPEG is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *   
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with GNU Make; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  21.  *
  22.  */
  23.  
  24. #include <windows.h>
  25. #include "IEEE1180TestDlg.h"
  26. #include "..\resource.h"
  27. #include "..\auxiliary.h"
  28. #include <CommCtrl.h> 
  29.  
  30. static CIEEE1180Dlg *gDlg;
  31.  
  32. static LRESULT CALLBACK DlgProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  33. {
  34.   return gDlg->DlgProc(hWnd, message, wParam, lParam);
  35. }
  36.  
  37. CIEEE1180Dlg::CIEEE1180Dlg( HWND hParentWnd, HINSTANCE hInst)
  38.   m_hParentWnd = hParentWnd; m_hInst = hInst;
  39.   gDlg = this;
  40. }
  41.  
  42. bool CIEEE1180Dlg::IsIEEE1180(void (* TestIdct)(DCTELEM *block) , char *pIdctId)
  43. {
  44.   if(!TestIdct)
  45.     return false;
  46.   m_pTestIdct = TestIdct;
  47.   m_pIdctId   = pIdctId;
  48.   m_bFinished = false;
  49.   return DialogBox(m_hInst, (LPCTSTR)IDD_IEEE1180DLG, m_hParentWnd, (DLGPROC)DlgProcHook)>0;
  50. }
  51.  
  52. LRESULT CALLBACK CIEEE1180Dlg::DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  53. {
  54.   int nTimer;
  55.   switch (message)
  56.   {
  57.         case WM_INITDIALOG:
  58.       // Disable the ok button
  59.       EnableWindow( GetDlgItem(hWnd, IDOK), false );
  60.       // Set the status text
  61.       strFinal = string("FlasKMPEG is analizing ") + m_pIdctId;
  62.  
  63.       // Create the thread
  64.       Create();
  65.  
  66.       // Create timer
  67.       nTimer = SetTimer(hWnd, 1, 20, NULL );      
  68.       return TRUE;
  69.  
  70.     case WM_TIMER:
  71.       SendDlgItemMessage(hWnd, IDC_PROGRESS, PBM_SETPOS, (WPARAM)m_obTester.GetProgress(), 0);
  72.       strFinal += " .";
  73.       SetDlgItemText( hWnd, IDC_EDIT, strFinal.c_str());
  74.       if(m_bFinished)
  75.       {
  76.           strFinal.erase();
  77.           strFinal = string("FlasKMPEG Analysis result: \r\n") + m_pIdctId;
  78.           strFinal += m_bIsIEEE1180 ? " Meets IEEE1180 spec" : " Does NOT meet IEEE1180 spec \r\n";
  79.           char tempStr[256];
  80.           sprintf(tempStr, "\r\nTest time: %0.3f seconds\r\n", (float)m_nTestTime/1000.0 );
  81.           strFinal += tempStr;
  82.  
  83.           strFinal += "\r\n\r\nAnalysis details:\r\n";
  84.           strFinal += m_obTester.GetResults();
  85.  
  86.           EnableWindow( GetDlgItem(hWnd, IDOK), true );
  87.  
  88.           SetDlgItemText( hWnd, IDC_EDIT, strFinal.c_str() );
  89.           KillTimer( hWnd, 1);
  90.       }
  91.  
  92.       break;
  93.     case WM_COMMAND:
  94.       if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
  95.       {
  96.         // Close timer
  97.         // Close thread first
  98.         Close();
  99.         EndDialog(hWnd, LOWORD(wParam));
  100.         return TRUE;
  101.       }
  102.       break;
  103.   }
  104.   return FALSE;
  105. }
  106.  
  107. DWORD CIEEE1180Dlg::ThreadProc()
  108. {
  109.   // Thread routine.
  110.   m_nTestTime = GetTickCount();
  111.   m_bIsIEEE1180 = m_obTester.IsIEEE1180( m_pTestIdct );
  112.   m_nTestTime = GetTickCount() - m_nTestTime;
  113.   m_bFinished = true;
  114.   return FALSE;
  115. }