Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8157083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:09:30+00:00 2026-06-06T17:09:30+00:00

I have created a routine to make the corners of Delphi visual controls to

  • 0

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;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:09:31+00:00Added an answer on June 6, 2026 at 5:09 pm

    There exist constructs or hacks to modify classes at runtime, see for example Replacing a component class in delphi and Changing component class at run-time on demand. However, as fas as I understand, you have to declare separate types of all occurring control types.

    An alternative is to transverse over all controls after the form’s creation, using the Controls and ControlCount properties:

      public
        procedure AfterConstruction; override;
      end;
    
    procedure ModifyControls(Window: TWinControl);
    var
      I: Integer;
    begin
      for I := 0 to Window.ControlCount - 1 do
        if Window.Controls[I] is TWinControl then
        begin
          ModifyControls(TWinControl(Window.Controls[I]));
          RoundCorners(TWinControl(Window.Controls[I]));
        end;
    end;
    
    procedure TForm1.AfterConstruction;
    begin
      inherited AfterConstruction;
      ModifyControls(Self);
    end;
    

    But beware of control recreation, which happens more then you would think. For instance, changing the BorderStyle property of an Edit results in recreating the Edit which undoes your modification. Redo the modification in those cases, providing you could track them all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to make a unix compatible windows delphi routine that confirms if a
In AS3, I have created a nice swear filter routine that imports a list
I have problem with Oracle 9.2 and JMS. I created PL/SQL routine to send
I have created some JQuery that will expand a div 'popup' on hover and
I have created an EDMX in visual studio 2010 SP1. It has been built
I have created an android application that calls (using kSOAP library) a SOAP based
All links works as I expect but now I have to make a custom
I want to write three concurrent routines that sends integer to each other. Now,
I have created a Sub-Class of NSOutlineView and used the below code to make
I'm attempting to make a generic routine within my program that will instantiate objects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.