Component Visible using Mouse

I have a project which has an Timage on the form. When i bring the mouse over it i want it to show a hidden panel and when i move the mouse off the image the panel should become invisible. I have put code in the image mouse move which is

if panel1.visible then panel1.hide else panel1.show;

However to get this to work i heve to move the mouse on to the image to show the panel and off and on to hide it

I want the panel to act as a hint.

How is it done?
Al_ShepstoneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ITugayCommented:
here is a sample:


  TForm1 = class(TForm)
    Image1: TImage;
    Panel1: TPanel;
  ....
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
  end;



procedure TForm1.CMMouseEnter(var Message: TMessage);
begin
  if Message.LParam = Integer(Image1) then
    Panel1.Visible := True;
end;

procedure TForm1.CMMouseLeave(var Message: TMessage);
begin
  if Message.LParam = Integer(Image1) then
    Panel1.Visible := False;
end;


----
Igor
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DaFoxCommented:
Hi.

Use the CM_MOUSELEAVE and CM_MOUSEENTER messages.


private
  procedure CmMouseEnter(var Msg : TCmMouseEnter); message CM_MOUSEENTER;
  procedure CmMouseLeave(var Msg : TCmMouseLeave); message CM_MOUSELEAVE;

...

procedure TForm1.CmMouseEnter(var Msg : TCmMouseEnter);
begin
  if (TImage(Msg.Sender) = Image1) then
   Label1.Caption := 'Over Me';
end;

procedure TForm1.CmMouseLeave(var Msg : TCmMouseLeave);
begin
  if (TImage(Msg.Sender) = Image1) then
   Label1.Caption := 'Not Over Me';
end;

(not tested!)

Markus
0
Al_ShepstoneAuthor Commented:
Thanks for your help

Al
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.