X
xinglong
Unregistered / Unconfirmed
GUEST, unregistred user!
下面的源码只是一个举例,大家看一看下面的源码对吗?
我希望明白组件开发里的Create事情能不能马上调用其事件
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
unit MyComp;
interface
uses
Windows, SysUtils, Classes, Dialogs;
Type
TFsXaudioSitus = (fsWindows, fsSystem, fsProgram);//这里定义我的枚举类型
TMyComp = Class(TComponent)
private
FsDelXaudio:Boolean;
FsXaudioSitus:TFsXaudioSitus;
procedure SetsDelXaudio(Value: Boolean);
procedure SetsXaudioSitus(Value: TFsXaudioSitus);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property sDelXaudio:Boolean read FsDelXaudio write SetsDelXaudio;
property sXaudioSitus:TFsXaudioSitus read FsXaudioSitus write SetsXaudioSitus;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyVCL', [TMyComp]);
end;
constructor TMyComp.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
if not(csDesigning in ComponentState) then//防止在设计期调用下面的过程
case FsXaudioSitus of//我在设计期已经把sXaudioSitus设为了fsSystem或fsProgram
fsWindows: //问题是这时的FsXaudioSitus值还是默认的第一个fsWindows
begin //是不是TMyComp还没有创建就不能马上调用?
//我的事件
end;
fsSystem:
begin
//我的事件
end;
fsProgram:
begin
//我的事件
end;
end;
end;
destructor TMyComp.Destroy;
begin
inherited Destroy;
end;
procedure TMyComp.SetsDelXaudio(Value: Boolean);
begin
if FsDelXaudio <> Value then FsDelXaudio := Value;
end;
procedure TMyComp.SetsXaudioSitus(Value: TFsXaudioSitus);
begin
if FsXaudioSitus <> Value then FsXaudioSitus := Value;
end;
end.
我希望明白组件开发里的Create事情能不能马上调用其事件
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
unit MyComp;
interface
uses
Windows, SysUtils, Classes, Dialogs;
Type
TFsXaudioSitus = (fsWindows, fsSystem, fsProgram);//这里定义我的枚举类型
TMyComp = Class(TComponent)
private
FsDelXaudio:Boolean;
FsXaudioSitus:TFsXaudioSitus;
procedure SetsDelXaudio(Value: Boolean);
procedure SetsXaudioSitus(Value: TFsXaudioSitus);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property sDelXaudio:Boolean read FsDelXaudio write SetsDelXaudio;
property sXaudioSitus:TFsXaudioSitus read FsXaudioSitus write SetsXaudioSitus;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyVCL', [TMyComp]);
end;
constructor TMyComp.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
if not(csDesigning in ComponentState) then//防止在设计期调用下面的过程
case FsXaudioSitus of//我在设计期已经把sXaudioSitus设为了fsSystem或fsProgram
fsWindows: //问题是这时的FsXaudioSitus值还是默认的第一个fsWindows
begin //是不是TMyComp还没有创建就不能马上调用?
//我的事件
end;
fsSystem:
begin
//我的事件
end;
fsProgram:
begin
//我的事件
end;
end;
end;
destructor TMyComp.Destroy;
begin
inherited Destroy;
end;
procedure TMyComp.SetsDelXaudio(Value: Boolean);
begin
if FsDelXaudio <> Value then FsDelXaudio := Value;
end;
procedure TMyComp.SetsXaudioSitus(Value: TFsXaudioSitus);
begin
if FsXaudioSitus <> Value then FsXaudioSitus := Value;
end;
end.