Mega Code Archive

 
Categories / Delphi / VCL
 

Ignore some editing characters in TEdit or TDBEdit

Title: Ignore some editing characters in TEdit or TDBEdit Question: In some situation you need edit component that should not accect some characters such as "+-()*&^%$#@!~" or other. How can write a component that fill this featuer? Answer: for wrtiting this component you can control WM_CHAR Message and mask your masked characters. such as this in your component. procedure WMChar(var Msg: TWMCHAR); message WM_CHAR; Mask your Entered character. procedure WMChar(var Msg: TWMCHAR); // can't accept '0'. begin if Org(Msg.CharCode) 48 then inherited; end;