0

I used this tutorial to create a transparent picture box: https://www.codeproject.com/Articles/25048/How-to-Use-Transparent-Images-and-Labels-in-Window

However the issue is when I move the Object it also moves the background, so for example if it starts as this: Original position

The transparent object is the image in the top left.

Then if I move the image it looks like this:

Second position of transparent image

It seems to drag the background with it.

The one thing I have figured out so far is that if the image is moved to the edge of the form then the background resets.

I assume this is because the OnPaint function is not run when the image is moved. but i tried manually running the function and it didn't fix the problem.

hbblue
  • 305
  • 3
  • 14
  • You're probably not invalidating the Parent. See the translucent Custom Control in the example here: [Translucent circular Control with text](https://stackoverflow.com/a/51435842/7444103), note the `OnMouseDown()`, `OnMouseMove()` overrides and the `InvalidateParent()` method. Try to add that Control to a Form and drag it around at run-time (note that double-buffering is not exactly your friend here) -- I haven't actually checked the code you linked, but it's quite probably the issue (a relatively *subtle* one, I'm not sure it can be *cured* with a couple of method calls). – Jimi May 09 '22 at 16:16
  • If you haven't noticed, you don't need to add any code to move that Control at run-time, it does it by itself, just click on it and drag it. – Jimi May 09 '22 at 16:33
  • Could you show your current code? Maybe you could refer tio [this.](https://stackoverflow.com/q/19910172) – Jiale Xue - MSFT May 10 '22 at 05:53

0 Answers0