Solved

Special Button!

Posted on 1997-06-14
5
137 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
ID: 1337039
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
ID: 1337040
 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
ID: 1337041
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
ID: 1337042
 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
ID: 1337043
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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