Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Special Button!

Posted on 1997-06-14
5
Medium Priority
?
144 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
sperling earned 300 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

715 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