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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CAn someone please help me create a OnMouseEnter for a Image?

Status
Not open for further replies.

stephbr

Technical User
Mar 25, 2007
1
US
Hi,
i'm new to both C++ and borland products and have been able to find my way around placing object to create a nice looking app. However i'm trying to create a button with an image on it and as i move the mouse over the button it changes the button look.

I've used an image, verse the buttons provided because they
1. don't except PNG or transparent graphics
2. as i move over the button it shows the outline of the button.

i've been able to create code that uses the OnMouseMove for the image, but i had to get real creative by placing to events one on the button and the other on the panel behind to give the effect.

If i could get some type of sample code for doing this with an Image (picture) i'd be greatful.

I've read about a OnMouseEnter for buttons on this forum but not sure what i really need to do....please remember i'm really wet behind the ears.

thank you
 
So if I understand you right, you have 2 images, one directly on top of the other, and behind them is a panel. When the mouse moves over Image1, you want to hide it and show Image2, then when the mouse leaves the images, you want to hide Image2 and show Image1. If that's correct, then your code should look somthing like this:

Code:
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
  if (Image1->Visible) 
  {
    Image1->Visible=false;
    Image2->Visible = true;
  }

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Panel1MouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
  if (!Image1->Visible) 
  {
    Image1->Visible=true;
    Image2->Visible = false;
  }

}
//---------------------------------------------------------------------------

Does that look like the solution that you came up with? If so it looks like a good solution to me.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top