我在做大屏幕的控制系统,需要在窗口里显示来自视频卡video口的视频流。厂家提供了一个vb的demo,可是我转成delphi之后就是显示不出来,我也不知道问题出在哪,因为函数返回值都是对的。下面是一部分代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, mmSystem, Clipbrd, Menus;
const
CONFIG_BASE = 100;
CONFIG_SOURCE_1 = (CONFIG_BASE + 10);
CONFIG_SOURCE_2 = (CONFIG_SOURCE_1 + 1);
CONFIG_SOURCE_3 = (CONFIG_SOURCE_1 + 2);
CONFIG_SOURCE_4 = (CONFIG_SOURCE_1 + 3);
CONFIG_SOURCE_5 = (CONFIG_SOURCE_1 + 4);
CONFIG_SOURCE_6 = (CONFIG_SOURCE_1 + 5);
CONFIG_SOURCE_MAX = CONFIG_SOURCE_6 ;
MCI_DGV_SETVIDEO_SRC_NTSC = $4000;
MCI_DGV_SETVIDEO_SRC_RGB = $4001;
MCI_DGV_SETVIDEO_SRC_SVIDEO = $4002;
MCI_DGV_SETVIDEO_SRC_PAL = $4003;
MCI_DGV_SETVIDEO_SRC_SECAM = $4004;
MCI_DGV_SETVIDEO_SRC_GENERIC = $4005 ;
CONFIG_TYPE_BASE = (CONFIG_BASE - MCI_DGV_SETVIDEO_SRC_NTSC + 20);
CONFIG_TYPE_NTSC = (CONFIG_TYPE_BASE + MCI_DGV_SETVIDEO_SRC_NTSC);
CONFIG_TYPE_RGB = (CONFIG_TYPE_BASE + MCI_DGV_SETVIDEO_SRC_RGB);
CONFIG_TYPE_SVIDEO = (CONFIG_TYPE_BASE + MCI_DGV_SETVIDEO_SRC_SVIDEO);
CONFIG_TYPE_PAL = (CONFIG_TYPE_BASE + MCI_DGV_SETVIDEO_SRC_PAL);
CONFIG_TYPE_SECAM = (CONFIG_TYPE_BASE + MCI_DGV_SETVIDEO_SRC_SECAM);
CONFIG_TYPE_GENERIC = (CONFIG_TYPE_BASE + MCI_DGV_SETVIDEO_SRC_GENERIC);
CONFIG_TYPE_MIN = CONFIG_TYPE_NTSC;
CONFIG_TYPE_MAX = CONFIG_TYPE_GENERIC;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
property1: TMenuItem;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure property1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
DrvError:LongInt;
implementation
{$R *.dfm}
uses Unit2;
procedure TForm1.FormCreate(Sender: TObject);
begin
//Close overlay left open from a previous run cut short by the debugger
mciSendStringA('close overlay', ' ', 0, 0 );
DrvError := mciSendStringA('open overlay ', ' ', 0, 0);
If DrvError <> 0 then
showmessage('MCI Error code ' + inttoStr(DrvError) + ' when opening device ');
IMage1.Picture.Assign(Clipboard);
DrvError := mciSendString(PChar('window overlay handle ' + inttoStr(self.Handle)), ' ', 0, 0);
If DrvError <> 0 then
showmessage( 'MCI Driver did not get the window handle Error code: ' + inttoStr(DrvError));
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
DrvError := mciSendString('window overlay handle default', ' ', 0, 0);
If DrvError <> 0 then
showmessage('MCI Error code: ' + inttoStr(DrvError) + ' while handle default ');
DrvError := mciSendString('close overlay', ' ', 0, 0);
If DrvError <> 0 then
showmessage('MCI Error code: ' + inttoStr(DrvError) + ' while handle default ');
end;
他那个vb的实例,formcreate之后就能显示图象了,为什么delphi不行?难道delphi的form和vb的form不一样?
procedure TForm1.property1Click(Sender: TObject);
begin
form2.show;
end;
end.