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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:10:49+00:00 2026-06-18T10:10:49+00:00

I have a custom button component that I have derived from TCustomButton. To make

  • 0

I have a custom button component that I have derived from TCustomButton.

To make it ownerdrawn I have overrided the CreateParams like so:

procedure TMyButton.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  with Params do
  begin
    Style := Style or BS_OWNERDRAW;
  end;
end;

My button works ok with my own painting etc, but what I would like to do is provide a Boolean Property in the Object Inspector which can be used to tell my button whether it should be ownerdrawn or not.

For example, if the Property is enabled the button paints with my own paint routines as an ownerdrawn button, if the Property is toggled off then it should paint as the themed Windows button style (like a regular TButton).

CreateParams tells my button it should be ownerdawn, but I want to provide an option to tell the button whether it should be ownerdrawn or not. By changing the property at designtime or through code at runtime, I want to tell my button whether to ownerdraw or not.

Is this possible to do and if so how?

  • 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-18T10:10:51+00:00Added an answer on June 18, 2026 at 10:10 am

    Adding the property and make CreateParams behave accordingly is not the problem I suppose. Taking the new setting in effect immediately probably is.

    Call RecreateWnd when the property is toggled. This will lead to dropping the current Windows handle, and recreating it, including making use of your overriden CreateParams routine.

    All in all:

    type
      TMyButton = class(TButtonControl)
      private
        FOwnerDraw: Boolean;
        procedure SetOwnerDraw(Value: Boolean);
      protected
        procedure CreateParams(var Params: TCreateParams); override;
      published
        property OwnerDraw: Boolean read FOwnerDraw write SetOwnerDraw
          default False;
      end;
    
    procedure TMyButton.CreateParams(var Params: TCreateParams);
    const
      OwnerDraws: array[Boolean] of DWORD = (0, BS_OWNERDRAW);
    begin
      inherited CreateParams(Params);
      Params.Style := Params.Style or OwnerDraws[FOwnerDraw];
    end;
    
    procedure TMyButton.SetOwnerDraw(Value: Boolean);
    begin
      if FOwnerDraw <> Value then
      begin
        FOwnerDraw := Value;
        RecreateWnd;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom control that is derived from TabItem , and I want
We have a custom JSF component that renders some buttons and a select box
Check out this jsbin . I have a form with a custom button that
I have a custom ButtonUI class that paints the button. Before drawing the text,
I have to create a custom compound button bar control in Android like the
I have a custom control that displays a tryAgain button when the control is
I have a custom component, ExportCommandButton, that has two attached properties. This component is
I have a JTabbedPane with a custom tab component. That component contains a JLabel
I have made a Custom Component in XML, consisting of a button with an
I have a custom component (which extends JPanel ). It looks something like this:

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.