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

  • Home
  • SEARCH
  • 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 3799120
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:40:58+00:00 2026-05-19T13:40:58+00:00

I made a custom numpad with numbers on it. It’s a frame and buttons

  • 0

I made a custom numpad with numbers on it. It’s a frame and buttons in it. I put this component onto the form. Now I don’t know how to capture the active control on the form and then send number specific to the button to this control.

Can someone help me please?

  • 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-19T13:40:59+00:00Added an answer on May 19, 2026 at 1:40 pm

    The easiest way IMO is to also store the number that is the caption of the button in the button’s Tag property. You can then use the same event handler for all buttons:

    procedure TForm1.NumButtonClick(Sender: TObject);
    var
      NumTyped: Integer;
    begin
      NumTyped := TButton(Sender).Tag;
    end;
    

    The other alternative is to read the caption in the event, but then you have to do a conversion from string to Integer, which will break if you accidentally assign a button without a numeric caption to the event handler:

    procedure TForm1.NumButtonClick(Sender: TObject);
    var
      NumTyped: Integer;
    begin
      NumTyped := StrToInt(TButton(Sender).Caption);
    end;
    

    Note that this way you don’t have to care about whether your component is the ActiveControl or not; you just assign the event handler to every one of your component’s buttons and nothing else, and then if the event is triggered you know that the active control is your component and which one of it’s buttons was clicked.

    EDIT: Based on the comment below, there’s a little more to the question than it appears.

    If you’re trying to send the number to a TEdit (your “textbox”), you have to do a couple of other things. First, don’t use TButtons or TBitBtns, as they get focus and will take the focus away from your Edit control. Use TSpeedButton instead. Set the Caption of each one you want to the number you want it to put in the TEdit.

    Second, since you want to put the content in the TEdit, you don’t need to bother with the tag. Set the event handler for all the TSpeedButtons to this one (which assumes your TEdit is Edit1):

    procedure TForm1.NumButtonClick(Sender: TObject);
    begin
      Edit1.SelText := TSpeedButton(Sender).Caption;
    end;
    

    This replaces any selected text in the TEdit Edit1 with the caption of the SpeedButton, or adds it at the current caret (edit cursor) position in the TEdit.

    If you’re looking to put it in any one of a number of TEdits, a slight change will handle that as well:

    procedure TForm1.NumButtonClick(Sender: TObject);
    begin
      if ActiveControl is TEdit then
        TEdit(ActiveControl).SelText := TSpeedButton(Sender).Caption;
    end;
    

    If this is still not what you’re looking to accomplish, please edit your original question and add more information to it, so we have a chance of helping you get your answer.

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

Sidebar

Related Questions

I've made a custom component based on MenuBar. This is the code <?xml version=1.0
I made a custom UITableView subclass and implemented this: - (void)scrollViewDidScroll:(UIScrollView *)scrollView { //
Made a custom ListCellRenderer: import java.awt.Component; import javax.swing.JCheckBox; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel;
I made a custom class. This is the h file @interface Player : NSObject
I'm not sure if these are custom made buttons or if they are standard,
I've made a custom control, it's a FlowLayoutPanel, into which I put a bunch
Made this custom alert box: <script type="text/javascript"> $(function () { var $alert = $('#alert');
I have made custom .xml layout for ListView. Now it looks: But it isn't
I made a custom TObjectList descendant designed to hold subclasses of a base object
I made a custom control that is basically a multiline TextBox that allows input,

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.