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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:00:57+00:00 2026-06-13T09:00:57+00:00

Not sure on what to make title please edit if needed. I have a

  • 0

Not sure on what to make title please edit if needed. I have a procedure

procedure TFZone1Mod7.ChangeText(sender: TObject);
var
  ShapeOrderNo: integer;
  FoundComponent: TComponent;
begin
  if TryStrToInt(copy(TShape(Sender).Name,6,MaxInt),ShapeOrderNo) then
    begin
      FoundComponent := FindComponent('label'+inttostr(ShapeOrderNo+12));
      if (FoundComponent is TLabel) then
            Label25.Caption := TLabel(FoundComponent).Caption
      else
          showmessage('not found');
    end;
  showmessage(TShape(sender).Name);

end;

so i call the procedure on a Shape1MouseEnter. So i would think (Self) would send shape1 but it dont it sends the form(TFZone1Mod7) How i can get it to send the shape?
here is how i am calling it.

procedure TFZone1Mod7.Shape1MouseEnter(Sender: TObject);
begin
    changetext(self);
end;
  • 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-13T09:00:58+00:00Added an answer on June 13, 2026 at 9:00 am

    Inside this method

    procedure TFZone1Mod7.Shape1MouseEnter
    

    Self is an object of type TFZone1Mod7. And that’s your form. Remember that Self refers to the instance associated with the active method. And in your code, the class is a form and so the instance, Self, is always a form instance.

    To know what Self is, look at the type that follows the procedure or function keyword. The Self instance is an instance of that type.

    In your situation, if you want to pass the shape you can pass either Shape1, or to be more general, Sender. The latter allows you to share one event handler between multiple shapes.

    This sort of mistake highlights why you should use checked casts with the as operator. When you make a mistake, you will get informed of it immediately and in a helpful way. Your unchecked casts just lead to hard to understand cryptic errors.

    So I’d probably be inclined to declare ChangeText as receiving a parameter of type TShape. And then calling it like this:

    ChangeText(Sender as TShape);
    

    And this allows you to remove the casts from ChangeText and confine them just to the event handlers which by necessity only have a TObject instance, Sender, available.

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

Sidebar

Related Questions

I have checked the source codes of ASIHTTPRequest and could not make sure which
I want to make sure I have the right meta desc/keyword and title text
I'm not sure if the title is correct (please comment if it is not).
Sorry, I wasn't sure exactly what title to give this and have not been
Someone please recommend a better title for this question. I'm not sure what to
I'm not sure how to make a common utilities file and use the methods
I'm not sure how to make a few parts of my form to populate
Not sure exactly what I need to do to make this work, so my
I need to make a mySQL query and am not sure what the format
I'm not sure if I'll be clear enough in my explaination to make you

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.