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


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); 
  private 
    { Private declarations } 
  public 
    { Public declarations } 
  end; 
 
var 
  formCaptureSet: TformCaptureSet; 
   
function ShellShowDirs(AHandle : HWND): String; 
 
implementation 
 
uses Main, shlobj; 
 
{$R *.dfm} 
 
function ShellShowDirs(AHandle : HWND): String; 
    var 
    BrowsingInfo : TBrowseInfo ;      // BrowsingInfo; 
    DirPath      : String ;           // char DirPath[MAX_PATH]; 
    FolderName   : string ;           // char FolderName[MAX_PATH]; 
    pItemId      : PItemIDList;       // LPITEMIDLIST ;    // ItemID; 
    strLast      : String; 
    strReal      : String; 
begin 
    DirPath := ''; 
    FolderName := ''; 
 
    // pad the strings with blanks, they have to be done this way or 
    // SHBrowseForFolderA and/or SHGetPathFromIDList gpf. 
    DirPath    := StringOfChar(' ', MAX_PATH); 
    FolderName := StringOfChar (' ' , MAX_PATH) ; 
 
    // handle dictates who owns the dialog which pops up. 
    BrowsingInfo.hwndOwner      := AHandle ; // self.Handle ; 
    BrowsingInfo.pszDisplayName := PChar(FolderName) ; 
    BrowsingInfo.lpszTitle      := PAnsiChar('请选择目录') ; 
    BrowsingInfo.ulFlags        := BIF_RETURNONLYFSDIRS 
                                    and BIF_DONTGOBELOWDOMAIN ; 
    BrowsingInfo.pidlRoot       := nil ; 
    BrowsingInfo.lpfn           := nil ;  // display the dialog 
    pItemID := SHBrowseForFolderA( BrowsingInfo ); 
 
    // determine what the selection was 
    SHGetPathFromIDList(pItemID, PChar(DirPath));  // back to caller 
    result := ''; 
    strReal := PChar(DirPath); 
    If strReal = '' Then 
        Exit; 
         
    strLast := RightStr(strReal, 1); 
    If strLast <> '\' Then 
        strReal := strReal + '\'; 
 
    result := strReal; 
    // pItemId actually points to some memory, so free it 
     GlobalFreePtr(pItemID); 
end; 
 
procedure TformCaptureSet.FormShow(Sender: TObject); 
    var 
    nCompNum : Integer; 
    strCom : WideString; 
    i : Integer; 
begin 
    //comboCapSize.Text := IntToStr(g_nCapWidth) + ' * ' + IntToStr(g_nCapHeight); 
    editFrameRate.Text := IntToStr(formMain.SDK30001.FrameRate); 
    editVideoPath.Text := g_strVideoPath; 
    editPicturePath.Text := g_strPicturePath; 
    checkAudio.Checked := g_bRecAudio; 
 
    //取得所有压缩算法 
    formMain.SDK30001.GetVideoCompressorCount(nCompNum); 
     
    For i := 0 To nCompNum - 1 Do 
    begin 
        formMain.SDK30001.GetOneVideoCompressor(i, strCom); 
 
        If (g_nCurComp = -1) And (strCom = 'XviD MPEG-4 Codec') Then 
            g_nCurComp := i; 
 
        comboVideoComp.Items.Add(strCom); 
    end; 
 
    If g_nCurComp = -1 Then 
        g_nCurComp := 0; 
 
    comboVideoComp.ItemIndex := g_nCurComp; 
 
    //抓BMP or JPG 
    If g_bBmp Then 
        radioBmp.Checked := True 
    Else 
        radioJpg.Checked := True; 
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); 
    var 
    nNewWidth : Integer; 
    nNewHeight : Integer; 
    nAudioDev : Integer; 
begin 
 
    //判断视频尺寸是否变化 
    nNewWidth := StrToInt(LeftStr(comboCapSize.Text, 3)); 
    nNewHeight := StrToInt(RightStr(comboCapSize.Text, 3)); 
 
    If (nNewWidth <> g_nCapWidth) Or (nNewHeight <> g_nCapHeight) Then 
    begin 
        g_nCapWidth := nNewWidth; 
        g_nCapHeight := nNewHeight; 
 
        If g_bConnected Then 
            formMain.SDK30001.Disconnect(); 
 
        formMain.SDK30001.Connect(0, True, g_nCapWidth, g_nCapHeight); 
    end; 
 
    //取得帧率 
    If formMain.SDK30001.FrameRate <> StrToInt(editFrameRate.Text) Then 
        formMain.SDK30001.FrameRate := StrToInt(editFrameRate.Text); 
 
    //更新全局变量 
    g_strVideoPath := editVideoPath.Text; 
    g_strPicturePath := editPicturePath.Text; 
    g_nCurComp := comboVideoComp.ItemIndex; 
 
    g_bBmp := radioBmp.Checked; 
 
    If checkAudio.Checked Then 
    begin 
        g_bRecAudio := True; 
        formMain.SDK30001.GetAudioCaptureDevCount(nAudioDev); 
        If nAudioDev > 0 Then 
            formMain.SDK30001.SetCurrentAudioCompressorNum(0); 
    end 
    Else 
    begin 
        g_bRecAudio := False; 
        formMain.SDK30001.SetCurrentAudioCompressorNum(-1); 
    end; 
 
    //关闭窗体 
    Close(); 
end; 
 
procedure TformCaptureSet.btnCancelClick(Sender: TObject); 
begin 
    //关闭窗体 
    Close(); 
end; 
 
end.