⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 多媒體視頻程序設計--使用Delphi 第五章 源碼 5-1 摄像机启动流程 5-2 取得视频设备驱动器数量及信息 5-3 视频采集窗口 5-4 摄像机联机与离线 5-5 视频设备驱
💻 PAS
字号:
unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,VFW, ExtCtrls;

type
  TForm1 = class(TForm)
    DriverIndexLabel: TLabel;
    DriverIndexComboBox: TComboBox;
    DriverNameLabel: TLabel;
    DriverNameText: TStaticText;
    DriverVersionLabel: TLabel;
    DriverVersionText: TStaticText;
    DriverCountLabel: TLabel;
    DriverCountText: TStaticText;
    VideoCapPanel: TPanel;
    ConnectButton: TButton;
    DisConnectButton: TButton;
    procedure DriverIndexComboBoxChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ConnectButtonClick(Sender: TObject);
    procedure DisConnectButtonClick(Sender: TObject);
  private
    { Private declarations }
    FVideoCapWinH:THandle;
    FIsConnect:Boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
wDriverIndex:DWORD;
DrvCount:integer;
DrvName:array[0..80] of char;
DrvVer:array[0..80] of char;

begin

 DrvCount:=0;

 for wDriverIndex:=0 to 9 do
 if capGetDriverDescription(wDriverIndex,DrvName,sizeof(DrvName),DrvVer,sizeof(DrvName)) then
 begin
  inc(DrvCount);
 end;
 DriverCountText.Caption:=inttostr(DrvCount);


 FVideoCapWinH:=capCreateCaptureWindow (
	  	      'TEST',WS_CHILD or WS_VISIBLE,0,0,VideoCapPanel.Width,VideoCapPanel.Height,VideoCapPanel.Handle,0);




 FIsConnect:=FALSE;



end;

procedure TForm1.DriverIndexComboBoxChange(Sender: TObject);
var
wDriverIndex:DWORD;
DrvName:array[0..80] of char;
DrvVer:array[0..80] of char;
errmsg:string;
begin

 if FIsConnect then DisConnectButtonClick(nil);

 wDriverIndex:= DriverIndexComboBox.ItemIndex;
 if capGetDriverDescription(wDriverIndex,DrvName,sizeof(DrvName),DrvVer,sizeof(DrvName)) then
 begin
  DriverNameText.Caption:= DrvName;
  DriverVersionText.Caption:= DrvVer;

 end
 else
 begin
  DriverNameText.Caption:= '';
  DriverVersionText.Caption:= '';
  Beep;
  errmsg:='Error: Driver Index='+inttostr(wDriverIndex)+'

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -