退出时捕获 PictureMask 验证 wwDBedit 控件的异常

问题描述 投票:0回答:3

我公司的项目中使用的是delphi。 我正在使用 infopower 的控件,并且我有一个 DBedit,其中设置了图片蒙版。如果插入错误的类型值,在退出控件时,我想捕获异常以更改异常消息。 我的问题是我无法理解何时发生图片蒙版验证。我尝试将 Try/Except 块放在 OnExit 事件上,但它没有被缓存,而是使用默认消息触发。

我在控件的原始代码中看到异常出现在私有的CMExit过程中,我无法覆盖它或了解哪个事件触发了它。

我问如何在代码中捕获该消息。

delphi exception mask
3个回答
1
投票

您可以将插入器类添加到表单并处理消息 CM_EXIT 中的异常。

type
  TwwDBEdit= class (wwdbedit.TwwDBEdit)
    procedure CMExit(var Message: TCMExit); message CM_EXIT;
  end;

  TForm1 = class(TForm)
    wwDBEdit1: TwwDBEdit; 
  //..... other declarations here
implementation

{$R *.dfm}
{ wwDBEdit1 }

procedure TwwDBEdit.CMExit(var Message: TCMExit);
begin    
  try
    inherited; // call the inherited handler within try
  except
    Showmessage('Your Code'); // and handle it in except
  end;

end;

0
投票
try
  // Code

except
  on E : Exception do begin
    if E.Message = 'Type here the originally exception text' then begin
      // Code
    end;

0
投票

我这样做了并且成功了,但是在我的单位中有几个 twwdbedit 字段,并且它向每个人显示相同的消息,我如何识别给出错误的字段?这样我就可以根据字段安排更改消息?

© www.soinside.com 2019 - 2024. All rights reserved.