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 8290357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:47:27+00:00 2026-06-08T12:47:27+00:00

I am trying to create a set of custom components like TEdit, TDBEdit, TComboBox

  • 0

I am trying to create a set of custom components like TEdit, TDBEdit, TComboBox with a new kind of border (rounded corner) and I have created this code:

unit RoundRectControls;

interface

uses
  SysUtils, Classes, Controls, StdCtrls, Windows, Messages, Forms;

type
  TRoundRectEdit = class(TEdit)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
    constructor Create(AOwner: TComponent); override;
    { Public declarations }
  published
    property BorderStyle default bsNone;
    property Ctl3D default False;
    { Published declarations }
  end;

procedure Register;
procedure DrawRoundedRect(Control: TWinControl);

implementation

constructor TRoundRectEdit.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  DrawRoundedRect(Self);
end;

procedure Register;
begin
  RegisterComponents('Eduardo', [TRoundRectEdit]);
end;

procedure DrawRoundedRect(Control: TWinControl);
var
   r: TRect;
   Rgn: HRGN;
begin
   with Control do
   begin
     r := ClientRect;
     rgn := CreateRoundRectRgn(r.Left, r.Top, r.Right, r.Bottom, 30, 30) ;
     Perform(EM_GETRECT, 0, lParam(@r)) ;
     InflateRect(r, - 4, - 4) ;
     Perform(EM_SETRECTNP, 0, lParam(@r)) ;
     SetWindowRgn(Handle, rgn, True) ;
     Invalidate;
   end;
end;

end.

But after I tried to put the component in the Form, this message came:

Control '' has no Parent

So, how to I fix that? I am new to construct components and I need a good tutorial on the web. Something tells me that I need to make that DrawRoundedRect outside the Constructor… But where?

Edit 1 – 2012-07-27 14:50

Result

Sertac Akyuz’s Answer was great and resolved the problem, but the result was kind of ugly. I don’t know what I am doing wrong. The text of the EditBox is too close to the top-left. Does anyone know how do I fix it?

  • 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-08T12:47:28+00:00Added an answer on June 8, 2026 at 12:47 pm

    You are requesting ‘ClientRect’ but the edit control window has not been created yet (no window, no rectangle). You can move your region modifying code to some place after it is created. Example:

    type
      TRoundRectEdit = class(TEdit)
      private
        { Private declarations }
      protected
        procedure CreateWnd; override;
        { Protected declarations }
      public
        constructor Create(AOwner: TComponent); override;
        ...
    
    constructor TRoundRectEdit.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
    //  DrawRoundedRect(Self);
    end;
    
    procedure TRoundRectEdit.CreateWnd;
    begin
      inherited;
      DrawRoundedRect(Self);
    end;
    

    The error message itself reflects the effort of the VCL to create the window once its handle has been requested. It can’t do so because it cannot resolve in what window the control is to be placed.

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

Sidebar

Related Questions

I'm trying to create a custom object that behaves properly in set operations. I've
I'm trying to create a custom set of classes that can be added to
I'm trying to create a set of custom file templates for IntelliJ. I basically
I'm trying to create this dialog: . When Spinner is set to custom value,
I'm trying to create a node form for a custom type. I have organic
I'm trying to create a custom ActionFilter which operates on a set of parameters
I am trying to create a list of a custom type that is set
I am trying to create a custom CStatic control in vc++ and have a
I'm trying to create a custom view component which looks like this: a component
I'm trying to create a set of custom objects of the class Point point.h

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.