Link to home
Start Free TrialLog in
Avatar of Al_Shepstone
Al_Shepstone

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of Igor UL7AAjr
Igor UL7AAjr
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DaFox
DaFox

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
Avatar of Al_Shepstone

ASKER

Thanks for your help

Al