Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Hover Text (Change text color when a mouse is placed over it)

Rabbi43Rabbi43 Member Posts: 10
[b][red]This message was edited by the Rabbi43 at 2002-6-26 17:39:14[/red][/b][hr]
In HTML you can make hover text; when you place your curser over a link, the text will change color.

How can I do the same thing in Delphi 6? I want to do that to a label or something so when a user puts his curser over the label, the text will change color.
I know how to do it in VB but the same method doesn't work in Delphi 6
How can I do that?

Thanks in advance.




Comments

  • Josh CodeJosh Code Member Posts: 675
    With a tlabel, there is a MouseMove event that will be called when the mouse moves over it. In that procedure change the font colour.

    ie. label1.font.color:=clRed;

    Under the MouseMove event for the form or whatever the label is on, change the color back.

    ie. label1.font.color:=clBlack;


    If you want you can change the font completely when the mouse moves over the label.

    : In HTML you can make hover text; when you place your curser over a link, the text will change color.
    :
    : How can I do the same thing in Delphi 6? I want to do that to a label or something so when a user puts his curser over the label, the text will change color.
    : I know how to do it in VB but the same method doesn't work in Delphi 6
    : How can I do that?
    :
    : Thanks in advance.
    :
    :
    :
    :
    :

  • Rabbi43Rabbi43 Member Posts: 10
    Thank you. Now there is another problem. I don't know the MouseMove event for labels. I'll use the help library but if someone knows is, please post a reply.
  • Josh CodeJosh Code Member Posts: 675
    It's actually the [b]On[/b]MouseMove event.

    1. Click on the label.
    2. From the main menu, Click View -> Object Inspector. The window lists the various properties of an object. At the top is tabs for properties and events.

    3. Click the events tab. Now it lists the various events for the label.

    4. Double-click the OnMouseMove event on the right side of the divider.
    The Code Editor window should appear. The code should look something like this:

    [b]procedure[/b] TForm1.Label1MouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
    [b]begin[/b]

    [b]end;[/b]

    5. The code should go between the begin and end.


    I hope I've explained it well enough.


    : Thank you. Now there is another problem. I don't know the MouseMove event for labels. I'll use the help library but if someone knows is, please post a reply.
    :

  • Rabbi43Rabbi43 Member Posts: 10
    [b][red]This message was edited by the Rabbi43 at 2002-6-26 19:48:35[/red][/b][hr]
    Thanks again.
    I'm very new to Delphi (you can tell) :)

    This is what I used:

    procedure TForm1.Label1MouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
    begin
    label1.font.color:=clRed;
    end;

    procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
    begin
    label1.font.color:=clBlack;
    end;

    end.

    Works like a charm :)
  • ezerjohnrezerjohnr davao cityMember Posts: 1

    thank you @rabbi43 :D
    it really works like a charm

Sign In or Register to comment.