Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Picture on rollover? 1

Status
Not open for further replies.

ug505

Programmer
Jan 2, 2010
52
0
0
US
I'm using Delphi 7, and I have a button I made. I want it to change when someone rolls their mouse over it and then change back when their mouse isn't on the button. The only event for pictures is OnMouseMove, I tried it but it doesn't change back. Can someone help me?
 
Those aren't events that are available.
 
It's not clear from the original posting if you have made your own button component or are using one from the VCL.

An easy solution is to write OnMouseMove handlers for the other components on the form (including TForm) which change the button back to its original state.

Another technique is to code a Timer event which checks the mouse position and alters the button depending on whether the mouse is over the button or not.

Without more information it is difficult the best solution.

Andrew
Hampshire, UK
 
The button is an image. I'm still new to Delphi and learning it almost by myself. I have 2 images, 1 normal, and the other looks pressed down. How would I change them back and forth on if the mouse is on it or not. (on = pressed down, off = normal)
 
Option 1.
when the mouse moves over the image the images OnMouseMove event is fired which sets the image to down.

when the mouse moves over the Panel or Form that the image is housed on the Panel or Forms OnMouseMove event is fired which sets the image back to up.

be sure to test the image state and only change it once, the event fires every pixel the mouse moves and redraws the image.

Option 2.
use a control that provides OnMouseEnter & OnMouseLeave

Aaron
 
If you are trying to change the image displayed, based upon the state (up, disabled, clicked, down) of TButton, then you are doing a lot of work for nothing. Use TBitBtn instead. It already has this functionality built in.
See "Glyph property (TBitBtn)" in Delphi Help.

Roo
Delphi Rules!
 
aaronjme's post was most helpful, thank you very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top