Link to home
Start Free TrialLog in
Avatar of sccheung
sccheung

asked on

Special Button!

I want to create a button which will change when the user place the mouse cursor over it(just like buttons in netscape and internet explorer).I can use the OnMouseMove event to do this. But how to change the button back to the original one when the user moves the mouse cursor away? I've tried to use  the OnMouseMove event of the form. But I found that if the button is very close to the border, the user can move the mouse away very quickly and the button will not change to the original one. This will also happen when that button is very close to another component(it is a TMemo) and the user move the mouse cursor to it very quickly. The buttons in IE and netscape communicator cannot be cheated by this method. How to do this?
ASKER CERTIFIED SOLUTION
Avatar of sperling
sperling

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 StevenB
StevenB

 I don't want to malign anyone elses answer, but there is, I believe, a better solution using the messages:

  message CM_MouseEnter;
  message CM_MouseLeave;

  If you use these messages (which admittedly are not well documented in delphi) then you can get very precise and neat control over the movement of the Mouse into and out of your component.

  Steven.


Avatar of sccheung

ASKER

Steven,
   I have tried Erik's solution and it works. After that, I want to try your solution but I cannot find the badly documented help. I can only find a list of component message which contains the messages you mentioned. I learn Delphi only 2 months ago and I do not know how  to use message. I and still saving up money to buy an advanced Delphi book. Can I know these advanced skills in advance? I am only a 15-year-old boy with very little pocket money. It will take me a very long time to save up enough money to buy that book.
 Infact there is NO help on these messages, rather than bad help. If you'd like some example code for a button which does what you're trying to do then I'd be more than happy to mail it to you. I wrote this button a while ago and it's pretty simple to understand. If you'd like the code then mail me at :
stemail@dial.pipex.com

  'Cause I can't keep paying 10 points to continue this here.

  Steven.
Steven's solution is in fact better and more correct than mine. The reason I didn't mention these messages were simply that they require more knowledge of Delphi than you seem to have, to be successfully implemented. The main problem is that these messages would require you to create a new component, whereas the SetCapture method allows you to drop a button on a form and work with the available events.

When you've used Delphi for a while, I'd suggest you use these messages to implement your own custom button that you could drop on any form, that would be a nice excercise in message handling and event creation.

Regards,

Erik.