why if i move window form then video cap stop?? |
尚未結案
|
ghyghost
一般會員 發表:3 回覆:8 積分:2 註冊:2003-03-16 發送簡訊給我 |
unit Unit1; interface uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, avicap; type
Tform1 = class(TForm)
Button2: TButton;
Button3: TButton;
SaveDialog: TSaveDialog;
Button1: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Panel1: TPanel;
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
private
ghyghost_cap_handle : THandle;
CapturingAVI : bool;
{ Private declarations }
public
{ Public declarations }
end; var
form1: Tform1;
//函数声明
function capCreateCaptureWindow(
lpszWindowName: PChar;
dwStyle: DWord;
x, y: Integer;
nWidth, nHeight: Integer;
hwndParent: THandle;
nID: Integer): THandle; stdcall; implementation const WM_CAP_START = WM_USER;
const WM_CAP_STOP = WM_CAP_START + 68;
const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 0;
const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
const WM_CAP_SAVEDIB = WM_CAP_START + 25;
const WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
const WM_CAP_SEQUENCE = WM_CAP_START + 62;
const WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20; var
ghyghost_cap_handle: Hwnd;
CapParms: TCapTureParms;
{$R *.DFM}
function capCreateCaptureWindow; external 'AVICAP32.dll' name
'capCreateCaptureWindowA'; procedure Tform1.Button2Click(Sender: TObject);
begin
try
ghyghost_cap_handle := capCreateCaptureWindow(
'my video cap',
WS_CHILD + WS_VISIBLE + WS_EX_CLIENTEDGE + WS_EX_DLGMODALFRAME,
0,
0,
Panel1.Width,
Panel1.Height,
Panel1.Handle,
0);
if (capDriverConnect(ghyghost_cap_handle, 0)) <> 0 then
begin
CapPreviewRate(ghyghost_cap_handle, 30);
CapPreview(ghyghost_cap_handle, 1);
end;
except
showmessage('you video cap bad');
end;
SendMessage(ghyghost_cap_handle, WM_CAP_SET_SCALE, WParam(true), 0);
end; procedure Tform1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
capDriverDisconnect(ghyghost_cap_handle);
end; procedure Tform1.Button3Click(Sender: TObject);
begin
SendMessage(ghyghost_cap_handle, WM_CAP_DLG_VIDEOFORMAT, 0, 0);
SendMessage(ghyghost_cap_handle, WM_CAP_SET_SCALE, WParam(true), 0);
end; procedure Tform1.FormCreate(Sender: TObject);
begin
CapturingAVI := false;
ghyghost_cap_handle := 0;
SaveDialog.Options:=[ofHideReadOnly, ofNoChangeDir, ofPathMustExist];
end; procedure Tform1.Button1Click(Sender: TObject);
begin
if ghyghost_cap_handle <> 0 then
begin
SendMessage(ghyghost_cap_handle, WM_CAP_DRIVER_DISCONNECT, 0, 0);
ghyghost_cap_handle := 0;
end;
end; procedure Tform1.Button4Click(Sender: TObject);
begin
//if ghyghost_cap_handle <> 0 then
// SendMessage(ghyghost_cap_handle, WM_CAP_GRAB_FRAME, 0, 0);
end; procedure Tform1.Button5Click(Sender: TObject);
begin
if ghyghost_cap_handle <> 0 then
begin
SaveDialog .DefaultExt := 'bmp';
SaveDialog .Filter := 'Bitmap files (*.bmp)|*.bmp';
if SaveDialog .Execute then
SendMessage(ghyghost_cap_handle,WM_CAP_SAVEDIB,0,longint(pchar(SaveDialog .FileName)));
end;
end; procedure Tform1.Button6Click(Sender: TObject);
begin
if ghyghost_cap_handle <> 0 then
begin
SaveDialog .DefaultExt := 'avi';
SaveDialog .Filter := 'AVI files (*.avi)|*.avi';
if SaveDialog .Execute then
begin
CapturingAVI := true;
SendMessage(ghyghost_cap_handle,WM_CAP_FILE_SET_CAPTURE_FILEA,0,Longint(pchar(SaveDialog .FileName)));
SendMessage(ghyghost_cap_handle, WM_CAP_SEQUENCE, 0, 0);
end;
end;
end; procedure Tform1.Button7Click(Sender: TObject);
begin
if ghyghost_cap_handle <> 0 then
begin
SendMessage(ghyghost_cap_handle, WM_CAP_STOP, 0, 0);
CapturingAVI := false;
end;
end; procedure Tform1.Button8Click(Sender: TObject);
begin
capDlgVideoCompression(ghyghost_cap_handle);
end; end. why if i move window form then video cap stop??
i am from china.my english is very poor.
sorry everyone. why if i move window form then video cap stop?? please help me....
|
ghyghost
一般會員 發表:3 回覆:8 積分:2 註冊:2003-03-16 發送簡訊給我 |
program Project; uses
Forms,
Unit1 in 'Unit1.pas' {form1}; {$R *.RES} begin
Application.Initialize;
Application.CreateForm(Tform1, form1);
Application.Run;
end. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\object form1: Tform1
Left = 386
Top = 53
Width = 544
Height = 375
Caption = 'My Video Cap'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnClose = FormClose
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Button2: TButton
Left = 16
Top = 16
Width = 97
Height = 25
Caption = 'Open Video Cap'
TabOrder = 0
OnClick = Button2Click
end
object Button3: TButton
Left = 16
Top = 56
Width = 97
Height = 25
Caption = 'Video Format'
TabOrder = 1
OnClick = Button3Click
end
object Button1: TButton
Left = 16
Top = 136
Width = 97
Height = 25
Caption = 'Close Video Cap'
TabOrder = 2
OnClick = Button1Click
end
object Button4: TButton
Left = 16
Top = 176
Width = 97
Height = 25
Caption = 'Button4'
TabOrder = 3
OnClick = Button4Click
end
object Button5: TButton
Left = 16
Top = 216
Width = 97
Height = 25
Caption = 'save bmp'
TabOrder = 4
OnClick = Button5Click
end
object Button6: TButton
Left = 16
Top = 256
Width = 97
Height = 25
Caption = 'start avi'
TabOrder = 5
OnClick = Button6Click
end
object Button7: TButton
Left = 16
Top = 296
Width = 97
Height = 25
Caption = 'stop avi'
TabOrder = 6
OnClick = Button7Click
end
object Button8: TButton
Left = 16
Top = 96
Width = 97
Height = 25
Caption = 'Compression'
TabOrder = 7
OnClick = Button8Click
end
object Panel1: TPanel
Left = 176
Top = 40
Width = 273
Height = 297
Caption = 'Panel1'
TabOrder = 8
end
object SaveDialog: TSaveDialog
Left = 120
Top = 296
end
end \\\\\\\\\\\\\\\\\\\in delphi5 thank you all!!
|
ghyghost
一般會員 發表:3 回覆:8 積分:2 註冊:2003-03-16 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |