delphiexceptionmask

Catch Exception of PictureMask Validation of wwDBedit control on exit


I use delphi in my company's project. I am using infopower's control and i've got a DBedit that in which have set up a picturemask. In case of an wrong type value insertion, on exiting of the control, i want to catch the exception in order to alter the exception message. My problem is that i cannot understand when picturemask validation happens. I try to put Try/Except block on the OnExit event but it isn't getting cached and is firing with the default message.

I have seen in the original code of the control that the exception comes inside of a CMExit procedure that is private and i cannot override it or understand which event triggers it.

I am asking how can i catch that message in my code.


Solution

  • You could add an interposer class to your form and handle the exception within the message 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;