×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

On VFP6, how to display label number when clicked when more than one
2

On VFP6, how to display label number when clicked when more than one

On VFP6, how to display label number when clicked when more than one

(OP)
I have a form that launches more than 40 labels when initiating. Each label has the name of the label number. I need to display the name of the label in a text box when one of those labels is clicked. It has to be on VP6. Any solution?

RE: On VFP6, how to display label number when clicked when more than one

In the click event of the label put:

thisform.text1.value = this.Caption  

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483: How to get the best response from the forum first.

RE: On VFP6, how to display label number when clicked when more than one

I would say thisform.text1.value = this.name, but Mike's idea remains.

It's, of course, easier if all the labeƶs are your derived class instead of the base label class. If you use the base label class you need to go into all 40 click events and add that line of code.
Since Bindevents() also is forbidden the only comfortable way to do that is using the form as a table and changing the code in the data it actually is.

I don't know what you mean by "launch", though. Your form either already has 40 labels or you create them add runtime, thisform.addobject(). Launching is a word I'd only use in conjunction with starting (launching) a new form. If you create 40 labels you can, of course, create a class of the label having that line of code in its click. As the code doesn't change for each label you only need to design that class once.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: On VFP6, how to display label number when clicked when more than one

(OP)
Olaf Dosschke seems to be the more ideal. Because the 40 labels might change further for 50 or any number. The only problem with me is that I do not know how to " create a class of the label having that line of code in its click. As the code doesn't change for each label you only need to design that class once." Could you teach me how? or show me an example?

RE: On VFP6, how to display label number when clicked when more than one

Create a class:

In the project manager click on the classes tab, click new. As classname enter mylabel. For "based on" pick label. For "store in" enter a file name, this will be a vcx file.
Now in the class designer change to the click event. The simplest way is to double click, you get to the code editor. Look at the header, it tells you which method or event of the object you edit. Now enter the code: thisform.text1.value = this.name

Now you can save this.

To put this on a form you can visually drag it from the vcx onto the form, you can write code that does a loop FOR i = 1 to 40 and adds 40 labels thisform.addobject("label"+transform(i),"mylabel") once you did SET CLASSLIB TO the vcx file. Of course, also set their positions, etc. and finally set them .visible = .t., but I want to concentrate on how to create the class.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: On VFP6, how to display label number when clicked when more than one

(OP)
Olaf, Thanks a lot. You have been of great help to me. I did what you wrote and worked perfectly! You are pushing me to continue asking more questions in this forum.
For this case,I did not find the class manager in the VFP6 menu. But I used the command windows with the statement MODIFY CLASS mylabel and continued doing the class. When inserting the class to the form, I did used the VFP6 menu FORM and then INCLUDE FILE, selected ALL and, at last.... everything working good.
Thanks again.

RE: On VFP6, how to display label number when clicked when more than one

I think you meant project manager.

To have all files belonging to an EXE under one roof. What you should start with is CREATE PROJECT.. Give it a try. It organizes all your files used together to build an executable.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: On VFP6, how to display label number when clicked when more than one

Quote:

I did not find the class manager in the VFP6 menu

There is no class manager. What Olaf was referring to was the project manager. You open the project manager from the File menu (assuming the project already exists). Then go to the Classes tab and click New.

But never mind. You found how to achieve the same objective from the command window, which is fine. (In fact, that's what I normally do.)

You say Olaf has been a great help to you. Did you know that Tek Tips has a feature that lets you flag a post as being particularly helpful? Just click the "Great post" link at the bottom right of the post in question. This will flag the post with a star, which is useful as it will let other forum visitors see at a glance which questions have been answered and which posts have been the most useful.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close