Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a program that displays a background picture and I want to set a small area of that picture as when I click in that area with the mouse to display an other small picture in an other place over the background picture, and then when i click again in that area, to hide the small picture that displayed with the previous click.

With other words that area that i want to be active on click has nothing to do with the picture that i want to appear and disappear, is in another place.

Help here guys

Thanks

What I have tried:

nothing yet
nothing yet
nothing yet
Posted
Updated 13-Mar-19 2:43am
v5
Comments
OriginalGriff 13-Mar-19 7:24am    
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
Ralf Meier 13-Mar-19 8:03am    
I completely agree with OG.
But to give you an advise : if you are working with Windows.Forms - make some Tests with the PictureBox-Control ...
tool__ 13-Mar-19 8:05am    
Thanks for your answer, I'm not getting paid for this project, and I was never a student, I only have finished high school, this program I try to make is for personal use, i'm not planning to sale it, and I dont think that will worth anything in money anyways, so i request your good faith on that. I'm not asking you to make all the work for me, just to guide me a little in C# where i have limited knowledge

The only thing i have tryed is to handle the PictureBox.Click event and load the small picture, but that requires to click on the picture itself to activate something, and I want to display the picture from a third seperated area...

1 solution

Just do it, It is plain simple. Record the position of the mouse click, issue a repaint, drawing (or not) the small image over the background one. See, for instance .net - How can I draw a small image over an image using Graphics library C# ? - Stack Overflow[^].
 
Share this answer
 
Comments
tool__ 13-Mar-19 9:14am    
How do i record the position of the mouse click?
CPallini 13-Mar-19 9:28am    
Store the values of the X,Y properties of the passed MouseEventArgs variable
(see https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.mouseeventargs?view=netframework-4.7.2) in member variables of your form.
tool__ 13-Mar-19 10:03am    
Thanks for the answer but as i said above my knowledge in C# is limited, unfortunately doesn't seems to me plain simple...

I had the idea to drag and drop a picturebox over the background image, size it in the area i want the click event and then not load any picture on it, but just make it transparent... unfortunately i couldn't make it transparent with any of the options on the properties...

Any ideas if somehow can an image box become transparent so the background image be visible through it?
Ralf Meier 13-Mar-19 10:38am    
The 1st Click-Event don't comes from your Picturebox - it comes from the Background (perhaps another PictureBox ? or your Form ?).
If you get this Click you should check the MousePosition for further Action ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900