| View previous topic :: View next topic |
| Author |
Message |
Never Again I post too much
Reputation: 0
Joined: 13 Jan 2007 Posts: 2000 Location: New Mexico
|
Posted: Tue Oct 16, 2007 9:37 pm Post subject: How to change the picture when mouse over it? (Delphi) |
|
|
| How would I be able to change the picture of a button from something like a green button to a blue button when I put the mouse over it?
|
|
| Back to top |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Tue Oct 16, 2007 9:47 pm Post subject: |
|
|
Procedure (objectname)mousemove(Sender : Tobject);
begin
/// code here.
end;
|
|
| Back to top |
|
 |
Never Again I post too much
Reputation: 0
Joined: 13 Jan 2007 Posts: 2000 Location: New Mexico
|
Posted: Tue Oct 16, 2007 9:56 pm Post subject: |
|
|
| I know that, but what would the code be?
|
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Wed Oct 17, 2007 5:26 am Post subject: |
|
|
here:
| Code: | procedure TForm2.Image1MouseEnter(Sender: TObject);
begin
image1.Picture.LoadFromFile('bluebutton.bmp');
end;
procedure TForm2.Image1MouseLeave(Sender: TObject);
begin
image1.Picture.LoadFromFile('Greenbutton.bmp');
end; |
|
|
| Back to top |
|
 |
Never Again I post too much
Reputation: 0
Joined: 13 Jan 2007 Posts: 2000 Location: New Mexico
|
Posted: Wed Oct 17, 2007 6:59 am Post subject: |
|
|
| I get an error "Undeclared identifier" when I try that.
|
|
| Back to top |
|
 |
HolyBlah Master Cheater
Reputation: 2
Joined: 24 Aug 2007 Posts: 446
|
Posted: Wed Oct 17, 2007 2:37 pm Post subject: |
|
|
| did u put an image component?
|
|
| Back to top |
|
 |
Uzeil Moderator
Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Wed Oct 17, 2007 4:26 pm Post subject: |
|
|
If you copy and pasted the code from HolyBlah, you need to learn the basics of objects.
My 2 cents:
You need to figure out what component you're using first. Your average TButton can't have it's color changed by beginner means. I'd suggest using a picture component as a button, or a speedbutton with 'flat' set to True and have a picture component beneath the button which you can change the color of on the speedbutton's mousemove/mouseover event(s).
I may be wrong on a few variable names, haven't messed with Delphi in a while.
_________________
|
|
| Back to top |
|
 |
|