Solved

Special Button!

Posted on 1997-06-14
5
133 Views
Last Modified: 2010-04-04
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?
0
Comment
Question by:sccheung
  • 2
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
sperling earned 100 total points
Comment Utility
When the mouse cursor first enters your button, call SetCapture. This'll give you all mouse messages regardless of where the cursor is located. As soon as the cursor is outside the bounds of your button, call ReleaseCapture to restore normal processing of mouse messages.

Regards,

Erik.

0
 
LVL 4

Expert Comment

by:StevenB
Comment Utility
 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.


0
 

Author Comment

by:sccheung
Comment Utility
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.
0
 
LVL 4

Expert Comment

by:StevenB
Comment Utility
 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.
0
 
LVL 3

Expert Comment

by:sperling
Comment Utility
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.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now