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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:43:57+00:00 2026-05-23T13:43:57+00:00

There are several third-pary controls (such as the Raize Components ) which have a

  • 0

There are several third-pary controls (such as the Raize Components) which have a close ‘cross’ button ‘option’ (eg the page control). My requirement is simpler, I’d like to plonk a cross ‘button’ aligned top right on to a TPanel and access its clicked event. Is there either a simple way of doint this without creating a TPanel descendent, or is there a paid or free library component that I can use?

  • 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-05-23T13:43:58+00:00Added an answer on May 23, 2026 at 1:43 pm

    I wrote a control for you.

    unit CloseButton;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Classes, Controls, UxTheme;
    
    type
      TCloseButton = class(TCustomControl)
      private
        FMouseInside: boolean;
        function MouseButtonDown: boolean;
      protected
        procedure Paint; override;
        procedure MouseMove(Shift: TShiftState; X: Integer; Y: Integer); override;
        procedure WndProc(var Message: TMessage); override;
        procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X: Integer;
          Y: Integer); override;
        procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X: Integer;
          Y: Integer); override;
      public
        constructor Create(AOwner: TComponent); override;
      published
        property Align;
        property Anchors;
        property Enabled;
        property OnClick;
        property OnMouseUp;
        property OnMouseDown;
      end;
    
    procedure Register;
    
    implementation
    
    procedure Register;
    begin
      RegisterComponents('Rejbrand 2009', [TCloseButton]);
    end;
    
    { TCloseButton }
    
    constructor TCloseButton.Create(AOwner: TComponent);
    begin
      inherited;
      Width := 32;
      Height := 32;
    end;
    
    function TCloseButton.MouseButtonDown: boolean;
    begin
      MouseButtonDown := GetKeyState(VK_LBUTTON) and $8000 <> 0;
    end;
    
    procedure TCloseButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
      Y: Integer);
    begin
      inherited;
      Invalidate;
    end;
    
    procedure TCloseButton.MouseMove(Shift: TShiftState; X, Y: Integer);
    begin
      inherited;
      if not FMouseInside then
      begin
        FMouseInside := true;
        Invalidate;
      end;
    end;
    
    procedure TCloseButton.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
      Y: Integer);
    begin
      inherited;
      Invalidate;
    end;
    
    procedure TCloseButton.Paint;
    
      function GetAeroState: cardinal;
      begin
        result := CBS_NORMAL;
        if not Enabled then
          result := CBS_DISABLED
        else
          if FMouseInside then
            if MouseButtonDown then
              result := CBS_PUSHED
            else
              result := CBS_HOT;
      end;
    
      function GetClassicState: cardinal;
      begin
        result := 0;
        if not Enabled then
          result := DFCS_INACTIVE
        else
          if FMouseInside then
            if MouseButtonDown then
              result := DFCS_PUSHED
            else
              result := DFCS_HOT;
      end;
    
    var
      h: HTHEME;
    begin
      inherited;
      if UseThemes then
      begin
        h := OpenThemeData(Handle, 'WINDOW');
        if h <> 0 then
          try
            DrawThemeBackground(h,
              Canvas.Handle,
              WP_CLOSEBUTTON,
              GetAeroState,
              ClientRect,
              nil);
          finally
            CloseThemeData(h);
          end;
      end
      else
        DrawFrameControl(Canvas.Handle,
          ClientRect,
          DFC_CAPTION,
          DFCS_CAPTIONCLOSE or GetClassicState)
    end;
    
    procedure TCloseButton.WndProc(var Message: TMessage);
    begin
      inherited;
      case Message.Msg of
        WM_MOUSELEAVE:
          begin
            FMouseInside := false;
            Invalidate;
          end;
        CM_ENABLEDCHANGED:
          Invalidate;
      end;
    end;
    
    end.
    

    Sample (with and without themes enabled):

    Screenshot
    Screenshot

    Just put this in a TPanel at the top-right corner and set Anchors to top and right.

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

Sidebar

Related Questions

There are several web applications which allow you to send photos from your mobile
There are several people about (myself being one of them) who have been developing
There are several ways to do this, but I'm not sure which one of
There are several advanced jQuery plugins which filter <div> s by corresponding id or
I have an app with several modules. There is only one module loaded at
Our project uses several third-party open-source libraries, some of which require custom modifications. For
I have an API DLL that several third party applications reference. Some of these
There are several types of objects in a system, and each has it's own
There are several ways to iterate over a result set. What are the tradeoff
There are several plugin options for building a search engine into your Ruby on

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.