Salı, Temmuz 10, 2018

If source formatter doesn't work...

I do not know why it happened. The source formatter (CTRL + D) isn't working on some files. I found a solution for this.

  1. Open Project Manager (CTRL + ALT + F11)
  2. Select the file that the source code formatter does not work with.
  3. Rename it. (e.g., Form1.pas >> Form101.pas)
  4. Press CTRL + D.
  5. Rename. (e.g., Form101.pas >> Form1.pas)
  6. Press CTRL + D.

That's all...


Perşembe, Temmuz 05, 2018

Catch the error of validation of TMaskEdit

type
   TMaskEdit = class(Vcl.Mask.TMaskEdit)
   protected
      procedure ValidateError; override;
   end;

   TForm1 = class(TForm)
      .
      .
      procedure FormCreate(Sender: TObject);
      .
      .

.
.
.

{ TMaskEdit }
// All TMaskEdits in your form will use this procedure.
procedure TMaskEdit.ValidateError;
begin
   try
      inherited; // Original ValidateError
   except
      // Validation error occurred!
      Self.Clear;
      // I preferred clear the text.
      // If you want you can prefer show any message.
   end;

end;

Is TMaskEdit empty?

Uses 
   Vcl.Mask,
   Vcl.ValEdit,
   System.MaskUtils, ...
.
.
.
function isMaskEditEmpty(me: TMaskEdit) : Boolean;
begin
   Result := FormatMaskText(me.EditMask, '') = me.Text;
end;
.
.
.