How can I change the image on the picture box when the mouse is over the picture box I know how to end the application when the mouse is over the picture box but what is the code for changing the picture C++ (I need to use mouse enter class)

Image type is .png

C++ has no inherent understanding of a mouse, a picture or a window. This is all heavily dependent on your chosen operating system and your chosen window manager.

Your wrong because i know it's possible i have done it before it was easy i dont know if its my question but what i need is picture box is going to load a diffrent image when the mouse over and when the mouse is not over it's going to go back to the image before and it should be easy the picture all in one location!

I'm not talking about background image i want to cahnge the image on picture box 1 C++ windows form application

That's the property of the PictureBox that you want to change. How have you set the image on the picturebox thusfar? Please read the link that I gave you or find a suitable tutorial on the subject.

Edited 5 Years Ago by jonsca: n/a

Yes there is an already iamge and im using the mouse enter class when the mouse it over the picture picture will be change to something else!

Through what method have you placed the image in the picturebox? Show the code that you use to initialize it. I have found it is easiest to set the image as "BackgroundImage" of the picturebox and then change it by replacing that BackgroundImage with a new one.

i didnt write any code it doesnt require code for puttting pics and i dont want background image if i do that that will rune my design my i know that system drawing might help me and you

Well, it certainly requires code to change the picture. Did you put the picture in through the properties window on the right side of the IDE?

I think you're misinterpreting background image here. I'm not talking about the Windows background, I'm talking about the image that is displayed in the picture box. I've never had any luck using the PictureBox.Image in this fashion, that's why I'm recommending setting and changing the backgroundimage of the picturebox, not whatever you have for the background of your application or the Windows background.

i know what you said i think i missexplained i already set an image for the picture box through properties and i have done nothing else!

Mate i need to sleep its late here i keep writting tomorrow if you can find anything just write i read it tomorrow

You didn't found anything anyideas any other way to do this

Edited 5 Years Ago by emreozpalamutcu: n/a

If you have set the image as a PictureBox Image using the properties window, you just change the image in your MouseEnter handler. You'll need a MouseLeave handler setting the picture back to what it was if you want that effect.

In the MouseEnter: yourPictureBoxNameHere->Image = Image::FromFile(YourNewImagePathString); In the MouseLeave: yourPictureBoxNameHere->Image = Image::FromFile(YourOriginalImagePathString); I'm not sure what the big deal was, you were 3/4 of the way there. I was suggesting you use the BackgroundImage property (which can be set in the Properties window just like the Image property can) because there's more control over how the image is placed. I did it your way with the Image and the picturebox came out scaled funny (I'm sure there's a way to change this with Image, but I was offering you a suggestion I was familiar with).

Edited 5 Years Ago by jonsca: n/a

This question has already been answered. Start a new discussion instead.