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


unit global; 
 
interface 
uses Windows, sdk3000; 
var 
g_nCard      : Integer; 
g_hWnd       : HWND; 
g_szVidSize  : SIZE; 
g_nCurVs     : Integer; // 当前VideoSource,从0开始 
g_nPlayState : Integer; //0:未连接 1:播放 2:暂停 3:停止 
g_strCurComp : String; 
 
// 捕获参数设置对应的全局变量 
g_nFrameRate : Integer; 
g_strVideoPath : String; 
g_strPicturePath : String; 
g_bBmp : Boolean; 
 
// 全局函数 
// 全局变量初始化 
procedure InitGlobalVar(); 
 
// 目录选择对话框 
function ShellShowDirs(AHandle : HWND): String; 
 
// 连接设备 
procedure Connect(); 
 
// 设置VideoSource 
procedure SetVs(vs : Integer); 
 
implementation 
 
uses shlobj, StrUtils, Graphics; 
 
procedure InitGlobalVar(); 
begin 
    //主窗口用到的全局变量 
    g_nCard := 0; 
    g_hWnd := HWND(0); 
    g_szVidSize.cx := 720; 
    g_szVidSize.cy := 576; 
    g_nCurVs := 0; 
    g_nFrameRate := 25; 
 
    g_strCurComp := 'XviD MPEG-4 Codec'; 
    g_strVideoPath := 'e:\'; 
    g_strPicturePath := 'e:\'; 
    g_bBmp := False; 
    g_nPlayState := 0;     
end; 
 
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 Connect(); 
begin 
    VCAConnectDevice( g_nCard, ToVcbool(True), g_hWnd,  g_szVidSize, VIDEOSOURCE(g_nCurVs), g_nFrameRate); 
 
    //全局变量更新 
    g_nPlayState := 1; 
end; 
 
// 设置VideoSource 
procedure SetVs(vs : Integer); 
begin 
    VCASwitchVideoSource(g_nCard, VIDEOSOURCE(vs), ToVcbool(True)); 
end; 
 
end.