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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:23:49+00:00 2026-06-13T03:23:49+00:00

I have 12 shapes Shape1 Shape2 ….. Shape12 and I have 12 labels Label13

  • 0

I have 12 shapes

Shape1
Shape2
.....
Shape12

and I have 12 labels

Label13
Label14
......
Label24

I was wondering if there is a way to write such a function, that on mouse enter on a shape would assign corresponding label to a different label, for example Label25:

Label25 :=  
OnMouseEnter
shape1 -> label13
shape2 -> label14
...
shape12 -> label24

So if the mouse entered Shape1, Label25 would become equal to Label13, and if mouse entered Shape2, Label25 would become equal to Label14 and continue till if mouse entered Shape12 Label25 would become equal to Label24.

I know I can write

label25 := labelxx 

on each of the mouse enter events. But thought there could be an easier way as the name of the label and shape correspond, where label # is 12 more then the shape # everytime.

After adding the suggested, I added this

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('failed try');

end;

procedure TFZone1Mod7.Shape1MouseEnter(Sender: TObject);
begin
    changetext(self);
end;

end.

but everytime its ran i get failed try.
Am i sending the info wrong?

  • 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-13T03:23:50+00:00Added an answer on June 13, 2026 at 3:23 am

    I don’t like this kind of a design, but well, you can use the common event handler for all your shapes and use the FindComponent function to find a component by name there. You might then write comething like this (please note that it’s untested, written just in browser):

    var
      ShapeOrderNo: Integer;
      FoundComponent: TComponent;
    begin
      // first try to convert a text behind "Shape", what should be a shape's order 
      // and if it's convertable to integer, then...
      if TryStrToInt(Copy(TShape(Sender).Name, 6, MaxInt), ShapeOrderNo) then
      begin
        // try to find a component with the name "label" + found shape order number
        // incremented by 12
        FoundComponent := FindComponent('label' + IntToStr(ShapeOrderNo + 12));
        // if the component is found, or to be more specific, if it's TLabel, then...
        if (FoundComponent is TLabel) then
          TLabel(FoundComponent).Caption := 'Hello from ' + TShape(Sender).Name;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You have 12 shapes: which you can make each out of five identical squares.
I have two shapes which are cross sections of a channel. I want to
let's say I have two shapes wrapped in Movieclip container. How can I detect
I have this image: In this image I have 11 shapes (look like ellipses).
I have two questions about java.awt.Shape . Suppose I have two Shape s, shape1
Help needed.. I have a organization layout which have rectangular shapes not in an
I'm using a custom JLayeredPane. I have several Shapes which needed to be drawn
I'm following this MVC model: http://java.sun.com/developer/technicalArticles/javase/mvc/ In my model I have an ArrayList shapes
I have added a ColorPropertyDescriptor to the Shapes example in GEF, however this displays
I have a Controls.Canvas with several shapes on it and would like to add

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.