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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:46:29+00:00 2026-06-02T22:46:29+00:00

I am developing custom component derived from TCustomControl class. I would like to add

  • 0

I am developing custom component derived from TCustomControl class. I would like to add new TFont based property that could be edited in design-time like for example in TLabel component. Basically what I want is to add user the option to change various atttributes of font (name, size, style, color and so on) without adding each of these attributes as separate property.

My first attempt:

class PACKAGE MyControl : public TCustomControl
{
...
__published:
    __property TFont LegendFont = {read=GetLegendFont,write=SetLegendFont};

protected:
    TFont __fastcall GetLegendFont();
    void __fastcall SetLegendFont(TFont value);
...
}

Compiler returns error “E2459 Delphi style classes must be constructed using operator new”. I also don’t know if I should use data type TFont or TFont*. It seems to me inefficient to create new object instance every time user change single attribute. I would appreciate code sample how can this be accomplished.

  • 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-02T22:46:30+00:00Added an answer on June 2, 2026 at 10:46 pm

    Classes derived from TObject must be allocated on the heap using the new operator. You are trying to use TFont without using any pointers, which will not work. You need to implement your property like this:

    class PACKAGE MyControl : public TCustomControl
    {
    ...
    __published:
        __property TFont* LegendFont = {read=FLegendFont,write=SetLegendFont};
    
    public:
        __fastcall MyControl(TComponent *Owner);
        __fastcall ~MyControl();
    
    protected:
        TFont* FLegendFont;
        void __fastcall SetLegendFont(TFont* value);
        void __fastcall LegendFontChanged(TObject* Sender);
    ...
    }
    
    __fastcall MyControl::MyControl(TComponent *Owner)
        : TCustomControl(Owner)
    {
        FLegendFont = new TFont;
        FLegendFont->OnChange = LegendFontChanged;
    }
    
    __fastcall MyControl::~MyControl()
    {
         delete FLegendFont;
    }
    
    void __fastcall MyControl::SetLegendFont(TFont* value)
    {
        FLegendFont->Assign(value);
    }
    
    void __fastcall MyControl::LegendFontChanged(TObject* Sender);
    {
        Invalidate();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently developing a custom control that derives from CStatic MFC class (Smart Device
I'm developing custom serializer as hobby project and I would like learn the TDD
I'm developing a custom control that doesn't inherit from Button. I want to implement
I am developing a custom component using JSF 1.2. My tag class extends UIComponentELTag
In the past few weeks I've been developing a custom PHP login class that
I am developing a custom control that needs it's viewstate to be loaded on
I'm developing a custom WordPress theme for a company, and I'd like to keep
I have been tasked with developing a Firefox add-on that is capable of registering
I'm developing custom Agent for LotusNotes 8.5. I'd like to use iCal4j jar to
I'm building a custom WPF control that derives from TabControl. In the ControlTemplate, I'm

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.