I have created a routine to make the corners of Delphi visual controls to be rounded.
Now what I want to do is ensure that every visual object like TMemo
, TEdit
and TPanel
comes rounded without having to call the function for everyone of them at the form creation.
How do I make an extension of the create method for each of these classes from my code (form unit), so they keep the name of the class and the normal behavior on other units?
procedure RoundCornersOf(Control: TWinControl) ;
var
R: TRect;
Rgn: HRGN;
begin
with Control do
begin
R := ClientRect;
rgn := CreateRoundRectRgn(R.Left, R.Top, R.Right, R.Bottom, 20, 20) ;
Perform(EM_GETRECT, 0, lParam(@r)) ;
InflateRect(r, - 4, - 4) ;
Perform(EM_SETRECTNP, 0, lParam(@r)) ;
SetWindowRgn(Handle, rgn, True) ;
Invalidate;
end;
end;