www.pudn.com > delphi-Sdk3000-ocx.zip > CaptureSet.pas, change:2005-05-20,size:4706b


unit CaptureSet; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, StdCtrls, StrUtils; 
 
type 
  TformCaptureSet = class(TForm) 
    Label1: TLabel; 
    Label2: TLabel; 
    Label3: TLabel; 
    Label4: TLabel; 
    Label5: TLabel; 
    Label6: TLabel; 
    editVideoPath: TEdit; 
    editPicturePath: TEdit; 
    editFrameRate: TEdit; 
    checkAudio: TCheckBox; 
    radioJpg: TRadioButton; 
    radioBmp: TRadioButton; 
    comboCapSize: TComboBox; 
    comboVideoComp: TComboBox; 
    btnOk: TButton; 
    btnCancel: TButton; 
    btnBrowseVideo: TButton; 
    btnBrowsePicture: TButton; 
    procedure FormShow(Sender: TObject); 
    procedure btnOkClick(Sender: TObject); 
    procedure btnCancelClick(Sender: TObject); 
    procedure btnBrowseVideoClick(Sender: TObject); 
    procedure btnBrowsePictureClick(Sender: TObject); 
    procedure FormCreate(Sender: TObject); 
  private 
    m_bFirstShow : Boolean; 
    m_bHasAudioDev : Boolean; 
    { Private declarations } 
  public 
    { Public declarations } 
  end; 
 
var 
  formCaptureSet: TformCaptureSet; 
   
implementation 
 
uses sdk3000, Global; 
 
{$R *.dfm} 
var 
s_nCurSize : Integer; 
s_nCurComp : Integer; 
s_bRecAudio : Boolean; 
 
procedure InitCaptureSetGlobal(); 
begin 
    s_nCurSize := 0; 
    s_nCurComp := -1; 
    s_bRecAudio := False; 
end; 
 
procedure TformCaptureSet.FormCreate(Sender: TObject); 
begin 
    InitCaptureSetGlobal(); 
    m_bFirstShow := True; 
    m_bHasAudioDev := False; 
end; 
 
procedure TformCaptureSet.FormShow(Sender: TObject); 
    var 
    nCompNum : Integer; 
	arrCompName : Array[0..12800] of AnsiChar; 
    i : Integer; 
    strCom : String; 
     
    nAudioDev : Integer; 
	arrDevName : Array[0..12800] of AnsiChar; 
begin 
    comboVideoComp.ItemIndex := s_nCurSize; 
    editFrameRate.Text := IntToStr(g_nFrameRate); 
    checkAudio.Checked := s_bRecAudio; 
    editVideoPath.Text := g_strVideoPath; 
    editPicturePath.Text := g_strPicturePath; 
     
    //抓BMP or JPG 
    radioBmp.Checked := g_bBmp; 
    radioJpg.Checked := (Not g_bBmp); 
 
    // 第一次显示,取得所有压缩算法,填在comboVideoComp中 
    If m_bFirstShow Then 
    begin 
        VCAEnumAudioCaptureDev(g_nCard, arrDevName, nAudioDev); 
        If nAudioDev > 0 Then 
            m_bHasAudioDev := True; 
             
        m_bFirstShow := False; 
 
        VCAEnumVideoCompressor(g_nCard, arrCompName, nCompNum); 
        For i := 0 To nCompNum - 1 Do 
        begin 
            strCom := PAnsiChar(arrCompName+128*i); 
            If (strCom = 'XviD MPEG-4 Codec') Then 
                s_nCurComp := i; 
 
            comboVideoComp.Items.Add(strCom); 
        end; 
 
        If s_nCurComp = -1 Then 
            s_nCurComp := 0; 
    end; 
 
    comboVideoComp.ItemIndex := s_nCurComp; 
end; 
 
procedure TformCaptureSet.btnBrowseVideoClick(Sender: TObject); 
    var 
    strPath : String; 
begin 
    strPath := ShellShowDirs(Handle); 
    If strPath <> '' Then 
        editVideoPath.Text := strPath; 
end; 
 
procedure TformCaptureSet.btnBrowsePictureClick(Sender: TObject); 
    var 
    strPath : String; 
begin 
    strPath := ShellShowDirs(Handle); 
    If strPath <> '' Then 
        editPicturePath.Text := strPath; 
end; 
 
procedure TformCaptureSet.btnOkClick(Sender: TObject); 
begin 
    //判断视频尺寸是否变化 
    If s_nCurSize <> comboCapSize.ItemIndex Then 
    begin 
        s_nCurSize := comboCapSize.ItemIndex; 
        g_szVidSize.cx := StrToInt(LeftStr(comboCapSize.Text, 3)); 
        g_szVidSize.cy := StrToInt(RightStr(comboCapSize.Text, 3)); 
        VCADisConnectDevice(g_nCard); 
        Connect(); 
    end; 
 
    If s_nCurComp <> comboVideoComp.ItemIndex Then 
    begin 
        g_strCurComp := comboVideoComp.Text; 
        s_nCurComp := comboVideoComp.ItemIndex; 
    end; 
 
    //取得帧率 
    If g_nFrameRate <> StrToInt(editFrameRate.Text) Then 
        g_nFrameRate := StrToInt(editFrameRate.Text); 
 
    // 是否录制音频 
    If (s_bRecAudio <> checkAudio.Checked) Then 
    begin 
        If checkAudio.Checked Then  // 要录制音频 
        begin 
            If m_bHasAudioDev Then 
                VCASetCurrentAudioCompressorNum(g_nCard, 0); 
        end 
        Else    // 不要录制音频 
            VCASetCurrentAudioCompressorNum(g_nCard, -1); 
 
        s_bRecAudio := checkAudio.Checked; 
    end; 
 
    //更新全局变量 
    g_strVideoPath := editVideoPath.Text; 
    g_strPicturePath := editPicturePath.Text; 
    g_bBmp := radioBmp.Checked; 
 
    //关闭窗体 
    Close(); 
end; 
 
procedure TformCaptureSet.btnCancelClick(Sender: TObject); 
begin 
    //关闭窗体 
    Close(); 
end; 
 
end.