0

this is my first ever question on this website but it has helped me a lot in the past.

i have a small (but annoying) problem with a project i am working on. i am using a picturebox control which loads a png file with transparent areas. the transparency part works perfectly fine, but i need the user to be able to drag this picturebox around with the mouse. the picturebox is contained within a panel with squares. the squares are drawn in an overridden OnPaint method of the panel.

the problem is that if i move the picturebox control, the area which is transparent does not draw the background fast enough and the squares are not drawn exactly where they should be. is there any way to get around this and make everything look nice and smooth?

i have attached a picture so that you can understand better what i am trying to say. for this example i am using just a line instead of the actual picture that i will be using so that everything is more obvious. notice the squares around the line, which are not in drawn properly.

http://s1084.photobucket.com/albums/j405/headbanging1638/?action=view&current=problem.jpg

ps: i am using color.transparent for the backcolor of the picturebox

2 Answers2

0

Maybe you could try to invalidate the layout on mousemove to force a faster rate of redraw?

dain
  • 6,475
  • 1
  • 38
  • 47
  • thanks for the answer, but the invalidate method is called in the mousemove event already :( –  Nov 25 '10 at 15:08
  • Hmm, maybe experimentally you could try what happens if you create a timer which forces - say - a 25 fps redraw loop on the dragged item on mouse press? – dain Nov 25 '10 at 15:13
  • timer for 25fps and .Refresh() instead of .Invalidate() and the problem is barely noticeable. think i`ll stick to this solution. thanks :) –  Nov 25 '10 at 15:31
0

I think pretty similar problem which I asked some time ago.

See my Question, and Answer which I accepted. I think it will help you.

Community
  • 1
  • 1
Javed Akram
  • 15,024
  • 26
  • 81
  • 118
  • hey, thanks for the link. gave me the idea of using .Refresh() instead of .Invalidate() –  Nov 25 '10 at 15:31