home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / delphi / kompon / d23456 / WAVICAP.ZIP / avicap / TAviCap / AviCap.pas next >
Encoding:
Pascal/Delphi Source File  |  2002-04-04  |  18.4 KB  |  596 lines

  1. unit AviCap;
  2. {
  3.  This code was written by : A. Waintrub
  4.  email: alexander@weintrub.de
  5.  This code is copyright 1997 by
  6.        A. Waintrub
  7. +++++++++++++++++++++++++++++++++++++++++++++++++++
  8. +        NUR F▄R PRIVATE NUTZUNG!!!               +
  9. +++++++++++++++++++++++++++++++++++++++++++++++++++}
  10.  
  11. interface
  12.  
  13. uses
  14.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, extctrls,
  15.   AviCapH,
  16. {$IFDEF VER140}DesignIntf, DesignEditors,
  17. {$ELSE}Dsgnintf,
  18. {$ENDIF}
  19.   AviCapDrvList, Dialogs;
  20.  
  21. type
  22.   TDriver = string;
  23.  
  24. type
  25.   TDriverProperty = class(TStringProperty)
  26.   private
  27.   public
  28.     procedure Edit; override;
  29.     function GetAttributes: TPropertyAttributes; override;
  30.   end;
  31.  
  32. type
  33.   TFileNameProperty = class(TStringProperty)
  34.   public
  35.     procedure Edit; override;
  36.     function GetAttributes: TPropertyAttributes; override;
  37.   end;
  38.  
  39. type
  40.   TAviCap = class(TCustomPanel)
  41.   private
  42.     { Private Declarations }
  43.     RequestMicroSecPerFrame: dword;
  44.     MakeUserHitOKToCapture: LongBool;
  45.     PercentDropForError: Byte;
  46.     Yield: bool;
  47.     IndexSize: dword;
  48.     ChunkGranularity: dword;
  49.     UsingDOSMemory: Bool;
  50.     NumVideoRequested: dword;
  51.     CaptureAudio: Bool;
  52.     NumAudioRequested: Byte;
  53.     KeyAbort: Word;
  54.     AbortLeftMouse: bool;
  55.     AbortRightMouse: bool;
  56.     LimitEnabled: bool;
  57.     TimeLimit: Byte;
  58.     MCIControl: bool;
  59.     StepMCIDevice: bool;
  60.     MCIStartTime: dword;
  61.     MCIStopTime: dword;
  62.     StepCaptureAt2x: bool;
  63.     StepCaptureAverageFrames: Byte;
  64.     AudioBufferSize: dword;
  65.     DisableWriteCache: bool;
  66.     StreamMaster: Word;
  67.     FConnected: boolean;
  68.     FDriver: TDriver;
  69.     FAviFileNAme: TFileName;
  70.     FOverlay: boolean;
  71.     FScale: boolean;
  72.     capturing: boolean;
  73.     FCaptureParms: TCaptureParms;
  74.     dummy: Boolean;
  75.     FOnMouseUp: TMouseMoveEvent;
  76.     FOnMouseMove: TMouseMoveEvent;
  77.     FOnMouseDown: TMouseMoveEvent;
  78.     FOnDblClick: TNotifyevent;
  79.     FOnClick: TNotifyevent;
  80.     Pic: TImage;
  81.     FPicture: TFileName;
  82.     F_4_to_3: Boolean;
  83.     FShowBlackScreen: Boolean;
  84.     function DriverIndex: Integer;
  85.     procedure SetDriver(const Value: TDriver);
  86.     procedure Connect(b: Boolean);
  87.     procedure SetAviFileName(S: TFileName);
  88.     procedure SetOverlay(b: boolean);
  89.     procedure SetScale(b: boolean);
  90.     procedure Disconnect;
  91.     procedure DlgSource(B: Boolean);
  92.     procedure DlgFormat(B: Boolean);
  93.     procedure DlgCompression(B: Boolean);
  94.     procedure DlgDisplay(B: Boolean);
  95.     procedure SetOnClick(const Value: TNotifyevent);
  96.     procedure SetOnDblClick(const Value: TNotifyevent);
  97.     procedure SetOnMouseDown(const Value: TMouseMoveEvent);
  98.     procedure SetOnMouseMove(const Value: TMouseMoveEvent);
  99.     procedure SetOnMouseUp(const Value: TMouseMoveEvent);
  100.     procedure SetPicture(const Value: TFileName);
  101.     procedure Set_4_to_3(const Value: Boolean);
  102.     procedure SetShowBlackScreen(const Value: Boolean);
  103.   protected
  104.     { Protected Declarations }
  105.   public
  106.     { Public Declarations }
  107.     DriverDescripton: TStringList;
  108.     CapWndHandle: THandle;
  109.     DC: HDC;
  110.     constructor Create(AOwner: TComponent); override;
  111.     destructor Destroy; override;
  112.     procedure paint; override;
  113.     procedure StartCapture;
  114.     procedure StopCApture;
  115.     property cap_DriverDescripton: TStringList read DriverDescripton;
  116.     property cap_WndHandle: THandle read CapWndHandle;
  117.   published
  118.     property cap_Connected: boolean read FConnected write connect;
  119.     property cap_DlgVideoCompression: boolean read dummy write DlgCompression;
  120.     property cap_DlgVideoSourece: boolean read dummy write DlgSource;
  121.     property cap_DlgVideoDisplay: boolean read dummy write DlgDisplay;
  122.     property cap_DlgVideoFormat: boolean read dummy write DlgFormat;
  123.     property cap_AviFileName: TFileName read FAviFileNAme write SetAviFileNAme;
  124.     property cap_Overlay: Boolean read FOverlay write SetOverlay;
  125.     property cap_Scale: Boolean read FScale write SetScale;
  126.     property cap_OptRequestMicroSecPerFrame: DWORD read RequestMicroSecPerFrame
  127.       write RequestMicroSecPerFrame;
  128.     property cap_OptMakeUserHitOKToCapture: Bool read MakeUserHitOKToCapture
  129.       write MakeUserHitOKToCapture;
  130.     property cap_OptPercentDropForError: Byte read PercentDropForError
  131.       write PercentDropForError;
  132.     property cap_OptYield: Bool read Yield
  133.       write Yield;
  134.     property cap_OptIndexSize: dword read IndexSize
  135.       write IndexSize;
  136.     property cap_OptChunkGranularity: dword read ChunkGranularity
  137.       write ChunkGranularity;
  138.     property cap_OptUsingDOSMemory: Bool read UsingDOSMemory
  139.       write UsingDOSMemory;
  140.     property cap_OptNumVideoRequested: dword read NumVideoRequested
  141.       write NumVideoRequested;
  142.     property cap_OptCaptureAudio: LongBool read CaptureAudio
  143.       write CaptureAudio;
  144.     property cap_OptNumAudioRequested: Byte read NumAudioRequested
  145.       write NumAudioRequested;
  146.     property cap_OptKeyAbort: Word read KeyAbort
  147.       write KeyAbort;
  148.     property cap_OptAbortLeftMouse: Bool read AbortLeftMouse
  149.       write AbortLeftMouse;
  150.     property cap_OptAbortRightMouse: Bool read AbortRightMouse
  151.       write AbortRightMouse;
  152.     property cap_OptLimitEnabled: Bool read LimitEnabled
  153.       write LimitEnabled;
  154.     property cap_OptTimeLimit: Byte read TimeLimit
  155.       write TimeLimit;
  156.     property cap_OptMCIControl: Bool read MCIControl
  157.       write MCIControl;
  158.     property cap_OptStepMCIDevice: Bool read StepMCIDevice
  159.       write StepMCIDevice;
  160.     property cap_OptMCIStartTime: dword read MCIStartTime
  161.       write MCIStartTime;
  162.     property cap_OptMCIStopTime: dword read MCIStopTime
  163.       write MCIStopTime;
  164.     property cap_OptStepCaptureAt2x: Bool read StepCaptureAt2x
  165.       write StepCaptureAt2x;
  166.     property cap_OptStepCaptureAverageFrames: Byte read StepCaptureAverageFrames
  167.       write StepCaptureAverageFrames;
  168.     property cap_OptAudioBufferSize: dword read AudioBufferSize
  169.       write AudioBufferSize;
  170.     property cap_OptDisableWriteCache: Bool read DisableWriteCache
  171.       write DisableWriteCache;
  172.     property cap_OptAVStreamMaster: Word read StreamMaster
  173.       write StreamMaster;
  174.     property Picture: TFileName read FPicture write SetPicture;
  175.     property cap_Driver: string read FDriver write SetDriver;
  176.     property OnDblClick: TNotifyevent read FOnDblClick write SetOnDblClick;
  177.     property OnClick: TNotifyevent read FOnClick write SetOnClick;
  178.     property OnMouseMove: TMouseMoveEvent read FOnMouseMove write SetOnMouseMove;
  179.     property OnMouseDown: TMouseMoveEvent read FOnMouseDown write SetOnMouseDown;
  180.     property OnMouseUp: TMouseMoveEvent read FOnMouseUp write SetOnMouseUp;
  181.     property _4_to_3: Boolean read F_4_to_3 write Set_4_to_3 default false;
  182.     property ShowBlackScreen: Boolean read FShowBlackScreen write SetShowBlackScreen;
  183.   end;
  184. procedure Register;
  185.  
  186. implementation
  187.  
  188. {$R AviCap.res}
  189.  
  190. var
  191.   hook: HHOOK;
  192.   _CapWndHandle, _ParentWindow: THAndle;
  193.   _AviCap: TAviCap;
  194.   _FOnMouseUp: TMouseMoveEvent;
  195.   _FOnMouseMove: TMouseMoveEvent;
  196.   _FOnMouseDown: TMouseMoveEvent;
  197.   _FOnDblClick: TNotifyevent;
  198.   _FOnClick: TNotifyevent;
  199.   Pressed: Byte = 0;
  200.  
  201. function GetMsgProc(code: Integer; wparam: WPARAM; lparam: pointer): LRESULT stdcall; //  <<<----------
  202. //   |
  203.   function MsgToShift(L: LongInt): TShiftState; //   |
  204.   begin //   |
  205.     result := []; //   |
  206.     if (l = WM_LBUTTONDOWN) or (L = WM_LBUTTONUP) then
  207.       Include(result, ssLeft); //   |
  208.     if (l = WM_MBUTTONDOWN) or (L = WM_MBUTTONUP) then
  209.       Include(result, ssMiddle); //   |
  210.     if (l = WM_RBUTTONDOWN) or (L = WM_RBUTTONUP) then
  211.       Include(result, ssRight); //   |
  212.     if GetKeyState(VK_MENU) < 0 then
  213.       Include(Result, ssAlt); //   |
  214.     if GetKeyState(VK_SHIFT) < 0 then
  215.       Include(Result, ssShift); //   |
  216.     if GetKeyState(VK_CONTROL) < 0 then
  217.       Include(Result, ssCtrl); //   |
  218.   end; //   |
  219. var //   |
  220.   msg: TagMsg; //   |
  221.   move: Boolean; //   |
  222. begin //   |
  223.   result := CallNextHookEx(//   |
  224.     HOOK, // handle to current hook                                                              //   |
  225.     Code, // hook code passed to hook procedure                                                  //   |
  226.     wparam, // value passed to hook procedure                                                    //   |
  227.     Integer(lparam) // value passed to hook procedure                                            //   |
  228.     ); //   |
  229.   Move := False; //   |
  230.   copymemory(@msg, lparam, Sizeof(tagmsg)); //   |
  231.   if msg.hwnd = _CapWndHandle then //   |
  232.   begin //   |
  233.     case msg.message of //   |
  234.       WM_LBUTTONDBLCLK, WM_RBUTTONDBLCLK, WM_MBUTTONDBLCLK: //   |
  235.         if assigned(_FOnDblClick) then
  236.           _FOnDblClick(_AviCap); //   |
  237.       WM_LBUTTONDOWN, WM_RBUTTONDOWN, WM_MBUTTONDOWN: //   |
  238.         begin //   |
  239.           if assigned(_FOnMouseDown) then
  240.             _FOnMouseDown(_AviCap, MsgToShift(msg.message), //   |
  241.               LOWORD(msg.lParam), HIWORD(msg.lParam)); //   |
  242.         end; //   |
  243.       WM_LBUTTONUP, WM_RBUTTONUP, WM_MBUTTONUP: //   |
  244.         if assigned(_FOnMouseUp) then
  245.           _FOnMouseUP(_AviCap, MsgToShift(msg.message), //   |
  246.             LOWORD(msg.lParam), HIWORD(msg.lParam)); //   |
  247.       WM_MOUSEMOVE: //   |
  248.         begin //   |
  249.           if assigned(_FOnMouseMove) then
  250.             _FOnMouseMove(_AviCap, MsgToShift(msg.message), //   |
  251.               LOWORD(msg.lParam), HIWORD(msg.lParam)); //   |
  252.           move := true; //   |
  253.         end; //   |
  254.     end; //   |
  255.     case msg.message of //   |
  256.       WM_LBUTTONUP: if (Pressed = 1) and assigned(_FOnClick) then
  257.           _FOnClick(_AviCap); //   |
  258.       WM_RBUTTONUP: if (Pressed = 2) and assigned(_FOnClick) then
  259.           _FOnClick(_AviCap); //   |
  260.       WM_MBUTTONUP: if (Pressed = 3) and assigned(_FOnClick) then
  261.           _FOnClick(_AviCap); //   |
  262.     end; //   |
  263.     if not move then //   |
  264.       case msg.message of //   |
  265.         WM_LBUTTONDOWN: Pressed := 1; //   |
  266.         WM_RBUTTONDOWN: Pressed := 2; //   |
  267.         WM_MBUTTONDOWN: Pressed := 3; //   |
  268.       else
  269.         Pressed := 0; //   |
  270.       end; //   |
  271.   end; //   ------------------------
  272.   if (msg.hwnd = _ParentWindow) and (msg.message = WM_MOUSEFIRST) {//   |} then
  273.     PostMessage(_CapWndHandle, WM_PAINT, 0, 0); //   |
  274. end; //   |
  275. //   |
  276. //   |
  277.  
  278. constructor TAviCap.Create(AOwner: TComponent); //   |
  279. var //   |
  280.   a1, a2: array[0..127] of char; //   |
  281.   b: Byte; //   |
  282. begin //   |
  283.   inherited Create(AOwner); //   |
  284.   parent := AOwner as TWinCOntrol; //   |
  285.   capturing := false; //   |
  286.   width := 260; //   |
  287.   height := 180; //   |
  288.   Pic := TImage.Create(self); //   |
  289.   Pic.Parent := Self; //   |
  290.   Pic.Stretch := True; //   |
  291.   Pic.Align := alClient; //   |
  292.   FPicture := ''; //   |
  293.   SetPicture(FPicture); //   |
  294.   DriverDescripton := TStringList.Create; //   |
  295.   for b := 0 to 8 do //   |
  296.     if capGetDriverDescriptionA(b, a1, 128, a2, 128) then //   |
  297.       DriverDescripton.Add(a1); //   |
  298.   fDriver := DriverDescripton.Strings[0]; //   |
  299.   CapWndHandle := capCreateCaptureWindowA('', WS_CHILD + WS_BORDER, //   |
  300.     0, 0, 0, 0, handle, 0); //   |
  301.   _CapWndHandle := CapWndHandle; //   |
  302.   capCaptureGetSetup(CapWndHandle, WParam(SizeOf(TCaptureParms)), //   |
  303.     LParam(@(FCaptureParms))); //   |
  304.   dc := Getdc(CapWndHandle); //   |
  305.   ZeroMemory(@a1, 128); //   |
  306.   capFileGetCaptureFile(CapWndHandle, 128, LParam(@a1)); //   |
  307.   FAviFileNAMe := a1; //   |
  308.   with FCaptureParms do //   |
  309.   begin //   |
  310.     RequestMicroSecPerFrame := dwRequestMicroSecPerFrame; //   |
  311.     MakeUserHitOKToCapture := fMakeUserHitOKToCapture; //   |
  312.     PercentDropForError := wPercentDropForError; //   |
  313.     Yield := fYield; //   |
  314.     IndexSize := dwIndexSize; //   |
  315.     ChunkGranularity := wChunkGranularity; //   |
  316.     UsingDOSMemory := fUsingDOSMemory; //   |
  317.     NumVideoRequested := wNumVideoRequested; //   |
  318.     CaptureAudio := fCaptureAudio; //   |
  319.     NumAudioRequested := wNumAudioRequested; //   |
  320.     KeyAbort := vKeyAbort; //   |
  321.     AbortLeftMouse := fAbortLeftMouse; //   |
  322.     AbortRightMouse := fAbortRightMouse; //   |
  323.     LimitEnabled := fLimitEnabled; //   |
  324.     TimeLimit := wTimeLimit; //   |
  325.     MCIControl := fMCIControl; //   |
  326.     StepMCIDevice := fStepMCIDevice; //   |
  327.     MCIStartTime := dwMCIStartTime; //   |
  328.     MCIStopTime := dwMCIStopTime; //   |
  329.     StepCaptureAt2x := fStepCaptureAt2x; //   |
  330.     StepCaptureAverageFrames := wStepCaptureAverageFrames; //   |
  331.     AudioBufferSize := dwAudioBufferSize; //   |
  332.     DisableWriteCache := fDisableWriteCache; //   |
  333.     StreamMaster := AVStreamMaster; //   |
  334.   end; //   |
  335.   FOverlay := True; //   |
  336.   if (not (csDesigning in ComponentState)) and (_CapWndHAndle <> 0) then //   |
  337.     HOOK := SetWindowsHookEx(//   |
  338.       WH_GETMESSAGE, // type of hook to install                          //   |
  339.       @GetMsgProc, // address of hook procedure      >>>>>>>>>----------------
  340.       hinstance, // handle of application instance
  341.       GetCurrentThreadID // identity of thread to install hook for
  342.       );
  343.   _AviCAp := self;
  344.   _ParentWindow := (AOwner as TWinControl).Handle;
  345. end;
  346.  
  347. destructor TAviCap.Destroy;
  348. begin
  349.   if FConnected then
  350.     disconnect;
  351.   DriverDescripton.free;
  352.   ReleaseDC(DC, CapWndHandle);
  353.   CloseHandle(CapWndHandle);
  354.   UnhookWindowsHookEx(hook);
  355.   inherited Destroy;
  356. end;
  357.  
  358. procedure TAviCap.Connect(b: Boolean);
  359. begin
  360.   if b then
  361.     if driverindex >= 0 then
  362.     begin
  363.       textout(dc, 10, 10, 'Connecting...', 13);
  364.       fconnected := capDriverConnect(CapWndHandle, DriverIndex);
  365.       SetOverlay(FOverlay);
  366.       pic.Hide;
  367.       ShowWindow(cap_WndHandle, SW_SHOW);
  368.     end
  369.     else
  370.       exception.Create('No drivers aviable')
  371.   else
  372.     disconnect;
  373. end;
  374.  
  375. procedure TAviCap.Disconnect;
  376. var
  377.   B: boolean;
  378. begin
  379.   fconnected := False;
  380.   pic.Show;
  381.   b := FOverlay;
  382.   SetOverlay(False);
  383.   capDriverDisconnect(CapWndHandle);
  384.   SetOverlay(b);
  385. end;
  386.  
  387. procedure TAviCap.Paint;
  388. var
  389.   L: LongINt;
  390. begin
  391.   if _4_to_3 then
  392.     height := width * 3 div 4;
  393.   if FConnected then
  394.     l := SWP_SHOWWINDOW
  395.   else if FShowBlackScreen then
  396.     l := SWP_SHOWWINDOW
  397.   else
  398.     l := SWP_HIDEWINDOW;
  399.   SetWindowPos(CapWndHandle, HWND_TOP, 1, 1, width - 3, height - 3, l);
  400.   if (csDesigning in ComponentState) and FShowBlackScreen then
  401.     textout(dc, 10, 10, PChar(Name), Length(Name));
  402.   inherited Paint;
  403. end;
  404.  
  405. procedure TAviCap.SetAviFileName(S: TFileName);
  406. begin
  407.   capFileSetCaptureFile(CapWndHandle, LParam(PChar(s)));
  408.   FAVIFileNAme := s;
  409. end;
  410.  
  411. procedure TAviCap.SetOverlay(b: boolean);
  412. begin
  413.   capOverlay(CapWndHandle, WPARAM(b));
  414.   FOverlay := b;
  415. end;
  416.  
  417. procedure TAviCap.SetScale(b: boolean);
  418. begin
  419.   capPreviewScale(CapWndHandle, WPARAM(b));
  420.   FScale := b;
  421. end;
  422.  
  423. procedure TAviCAp.StartCapture;
  424. var
  425.   b: Boolean;
  426. begin
  427.   SetAviFileName(FAviFileNAme);
  428.   b := FOverlay;
  429.   SetOverlay(false);
  430.   capCaptureSetSetup(CapWndHandle, WParam(SizeOf(FCaptureParms)),
  431.     LParam(@FCaptureParms));
  432.   capPreview(CapWndHandle, WPARAM(True));
  433.   capCaptureSequence(CapWndHandle);
  434.   setOverlay(b);
  435. end;
  436.  
  437. procedure TAviCAp.StopCapture;
  438. begin
  439.   capCaptureStop(CapWndHandle);
  440. end;
  441.  
  442. procedure TAviCap.DlgSource(B: Boolean);
  443. begin
  444.   capDlgVideoSource(CapWndHandle);
  445. end;
  446.  
  447. procedure TAviCAp.DlgFormat(B: Boolean);
  448. begin
  449.   capDlgVideoFormat(CapWndHandle);
  450. end;
  451.  
  452. procedure TAviCap.DlgCompression(B: Boolean);
  453. begin
  454.   capDlgVideoCompression(CapWndHandle);
  455. end;
  456.  
  457. procedure TAviCap.DlgDisplay(B: Boolean);
  458. begin
  459.   capDlgVideoDisplay(CapWndHandle);
  460. end;
  461.  
  462. procedure TAviCap.SetDriver(const Value: TDriver);
  463. begin
  464.  
  465.   if fconnected then
  466.     capDriverDisconnect(CapWndHandle);
  467.   if DriverDescripton.IndexOf(Value) >= 0 then
  468.     FDriver := Value;
  469.   if FConnected then
  470.     capDriverConnect(CapWndHandle, DriverIndex);
  471. end;
  472.  
  473. function TAviCap.DriverIndex: INteger;
  474. begin
  475.   result := DriverDescripton.IndexOf(FDriver)
  476. end;
  477.  
  478. procedure TAviCap.SetOnClick(const Value: TNotifyevent);
  479. begin
  480.   FOnClick := Value;
  481.   _FOnClick := FOnClick
  482. end;
  483.  
  484. procedure TAviCap.SetOnDblClick(const Value: TNotifyevent);
  485. begin
  486.   FOnDblClick := Value;
  487.   _FOnDblClick := FOnDblClick
  488. end;
  489.  
  490. procedure TAviCap.SetOnMouseDown(const Value: TMouseMoveEvent);
  491. begin
  492.   FOnMouseDown := Value;
  493.   _FOnMouseDown := FOnMouseDown
  494. end;
  495.  
  496. procedure TAviCap.SetOnMouseMove(const Value: TMouseMoveEvent);
  497. begin
  498.   FOnMouseMove := Value;
  499.   _FOnMouseMove := FOnMouseMove
  500. end;
  501.  
  502. procedure TAviCap.SetOnMouseUp(const Value: TMouseMoveEvent);
  503. begin
  504.   FOnMouseUp := Value;
  505.   FOnMouseUp := FOnMouseUp
  506. end;
  507.  
  508. procedure TAviCap.SetPicture(const Value: TFileName);
  509.   procedure LoadDefPic;
  510.   var
  511.     res, BufSize: Integer;
  512.     WMF: TMetaFile;
  513.     Str: TMemoryStream;
  514.   begin
  515.     res := FindResource(hinstance, 'PIC', 'WMF');
  516.     BufSize := SizeofResource(HInstance, res);
  517.     Str := TMemoryStream.Create;
  518.     Str.SetSize(BufSize);
  519.     copymemory(str.Memory, LockResource(LoadResource(HInstance, res)), BufSize);
  520.     wmf := TMetaFile.Create;
  521.     wmf.LoadFromStream(str);
  522.     pic.Picture.Assign(wmf);
  523.     str.Free;
  524.     wmf.Free;
  525.   end;
  526. begin
  527.   if Value = '' then
  528.     LoadDefPic
  529.   else
  530.     pic.Picture.LoadFromFile(Value);
  531.   FPicture := Value;
  532. end;
  533.  
  534. procedure TAviCap.Set_4_to_3(const Value: Boolean);
  535. begin
  536.   F_4_to_3 := Value;
  537.   repaint;
  538. end;
  539.  
  540. procedure TAviCap.SetShowBlackScreen(const Value: Boolean);
  541. begin
  542.   FShowBlackScreen := Value;
  543.   repaint;
  544. end;
  545.  
  546. { TDriverProperty }
  547.  
  548. procedure TDriverProperty.Edit;
  549. var
  550.   F: TFDrvList;
  551. begin
  552.   f := TFDrvList.Create(Application);
  553.   with f do
  554.   begin
  555.     ListBox1.Items := TAviCap(GetComponent(0)).DriverDescripton;
  556.     ShowModal;
  557.     if modalresult = mrOK then
  558.       TAviCap(GetComponent(0)).cap_Driver := getValue;
  559.     free;
  560.   end;
  561. end;
  562.  
  563. function TDriverProperty.GetAttributes: TPropertyAttributes;
  564. begin
  565.   Result := [paDialog];
  566. end;
  567.  
  568. { TFileNameProperty }
  569.  
  570. procedure TFileNameProperty.Edit;
  571. begin
  572.   with TOpenDialog.Create(Application) do
  573.   begin
  574.     filename := ExtractFileName(GetValue);
  575.     InitialDir := ExtractFilePath(GetValue);
  576.     if Execute then
  577.       SetValue(FileName);
  578.     Free
  579.   end;
  580. end;
  581.  
  582. function TFileNameProperty.GetAttributes: TPropertyAttributes;
  583. begin
  584.   Result := [paMultiSelect, paDialog];
  585. end;
  586.  
  587. procedure Register;
  588. begin
  589.   RegisterComponents('Free', [TAviCap]);
  590.   RegisterPropertyEditor(TypeInfo(TDriver), TAviCap, '', TDriverProperty);
  591.   RegisterPropertyEditor(TypeInfo(TFileName), TAviCap, '', TFileNameProperty);
  592. end;
  593.  
  594. end.
  595.  
  596.