home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / dspack / DSPACK231.exe / {app} / Demos / BCB6 / Playcap / main.cpp next >
Encoding:
C/C++ Source or Header  |  2003-01-18  |  2.3 KB  |  70 lines

  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #pragma hdrstop
  5.  
  6. #include "main.h"
  7. //---------------------------------------------------------------------------
  8. #pragma package(smart_init)
  9. #pragma link "DSPack"
  10. #pragma resource "*.dfm"
  11. TMainForm *MainForm;
  12. TSysDevEnum *SysDev;
  13.  
  14. //---------------------------------------------------------------------------
  15. __fastcall TMainForm::TMainForm(TComponent* Owner)
  16.         : TForm(Owner)
  17. {
  18. }
  19. //---------------------------------------------------------------------------
  20. void __fastcall TMainForm::FormCreate(TObject *Sender)
  21. {
  22.   SysDev = new TSysDevEnum(CLSID_VideoInputDeviceCategory);
  23.   if (SysDev->CountFilters > 0) {
  24.     int i;
  25.     TMenuItem *Device;
  26.     for(i = 0; i < SysDev->CountFilters; i++) {
  27.       Device = new TMenuItem(Devices);
  28.       Device->Caption = SysDev->Filters[i].FriendlyName;
  29.       Device->Tag = i;
  30.       Device->OnClick = DevicesClick;
  31.       Devices->Add(Device);
  32.     }
  33.   };
  34. }
  35. //---------------------------------------------------------------------------
  36.  
  37.  
  38. void __fastcall TMainForm::DevicesClick(TObject *Sender)
  39. {
  40.   FilterGraph->ClearGraph();
  41.   FilterGraph->Active = false;
  42.   Filter->BaseFilter->Moniker = SysDev->GetMoniker(((TMenuItem *)Sender)->Tag);
  43.   FilterGraph->Active = true;
  44.   ICaptureGraphBuilder2 *Graph = NULL;
  45.   IBaseFilter *SourceFilter = NULL;
  46.   IBaseFilter *VideoFilter = NULL;
  47.   CheckDSError(FilterGraph->QueryInterface(IID_ICaptureGraphBuilder2, &Graph));
  48.   CheckDSError(VideoWindow->QueryInterface(IID_IBaseFilter, &VideoFilter));
  49.   CheckDSError(Filter->QueryInterface(IID_IBaseFilter, &SourceFilter));
  50.   Graph->RenderStream(&PIN_CATEGORY_PREVIEW, NULL, SourceFilter, NULL, VideoFilter);
  51.   FilterGraph->Play();
  52.   Graph->Release();
  53.   VideoFilter->Release();
  54.   SourceFilter->Release();
  55. }
  56. //---------------------------------------------------------------------------
  57.  
  58. void __fastcall TMainForm::FormDestroy(TObject *Sender)
  59. {
  60.   delete SysDev;
  61. }
  62. //---------------------------------------------------------------------------
  63.  
  64. void __fastcall TMainForm::FormCloseQuery(TObject *Sender, bool &CanClose)
  65. {
  66.   FilterGraph->Active = false;        
  67. }
  68. //---------------------------------------------------------------------------
  69.  
  70.