type
TF_Root = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure CreateError(const Msg: string; Sender: TWinControl; Ico: smallint);//错误提示
published end; TError = class(Exception) //自定义的错误类
public
SenderObject: TWinControl;
IcoType: smallint;
constructor Create(const Msg: string; Sender: TWinControl; Ico: smallint);
end;var
F_Root: TF_Root;implementation{$R *.dfm}{ TError }constructor TError.Create(const Msg: string; Sender: TWinControl;
Ico: smallint);
begin
inherited Create(Msg);
SenderObject:=Sender;
if SenderObject<>nil then SenderObject.SetFocus;
IcoType:=0;
if Ico > 0 then IcoType:=Ico;
end;{ TF_Root }procedure TF_Root.CreateError(const Msg: string; Sender: TWinControl;
Ico: smallint);
var flag: LongInt;
Info: String;
begin
if Pos('Msg',Msg) > 0 then
begin
Case Ico of
1: begin flag:=MB_OK+MB_ICONWARNING; Info:='注意'; end;
2: begin flag:=MB_OK+MB_ICONERROR; Info:='错误'; end
else begin flag:=MB_OK+MB_ICONINFORMATION; Info:='提示'; end;
end;
MessageBox(Screen.ActiveForm.Handle,PChar(Copy(Msg,5,Length(Msg)-5)),PChar(Info),flag+MB_APPLMODAL);
end;
Raise TError.Create(Msg,Sender,Ico);
end;1、我是新手,请帮我解释一下每行的意义
2、如何调用此错误处理程序Thanks!
TF_Root = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure CreateError(const Msg: string; Sender: TWinControl; Ico: smallint);//错误提示
published end; TError = class(Exception) //自定义的错误类
public
SenderObject: TWinControl;
IcoType: smallint;
constructor Create(const Msg: string; Sender: TWinControl; Ico: smallint);
end;var
F_Root: TF_Root;implementation{$R *.dfm}{ TError }constructor TError.Create(const Msg: string; Sender: TWinControl;
Ico: smallint);
begin
inherited Create(Msg);
SenderObject:=Sender;
if SenderObject<>nil then SenderObject.SetFocus;
IcoType:=0;
if Ico > 0 then IcoType:=Ico;
end;{ TF_Root }procedure TF_Root.CreateError(const Msg: string; Sender: TWinControl;
Ico: smallint);
var flag: LongInt;
Info: String;
begin
if Pos('Msg',Msg) > 0 then
begin
Case Ico of
1: begin flag:=MB_OK+MB_ICONWARNING; Info:='注意'; end;
2: begin flag:=MB_OK+MB_ICONERROR; Info:='错误'; end
else begin flag:=MB_OK+MB_ICONINFORMATION; Info:='提示'; end;
end;
MessageBox(Screen.ActiveForm.Handle,PChar(Copy(Msg,5,Length(Msg)-5)),PChar(Info),flag+MB_APPLMODAL);
end;
Raise TError.Create(Msg,Sender,Ico);
end;1、我是新手,请帮我解释一下每行的意义
2、如何调用此错误处理程序Thanks!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货