transparent userctrl-background image allignemnt prblm

bwells

Regular
Joined
Feb 25, 2003
Messages
84
I have a form with a background image. In the form is a user control. I have set the style of the user control to support transparent background. I have also set the color to be transparent. When the user control is drawn in the form, it sometimes show the image in the background fine,but other times, the image in the background is not lined up with the edges of the panel. It looks like the user control is holding on to a different rendition of the form background image that is slightly off centered.

Is there a way to make the image that is showing through the user control be exactly what is in the form background image? I am guessing I have to override the paint method, but the form should not be painting anything in the background, right?

Does'nt the child user control get invalidated when the parent form gets invalidated?

thanks
Bryan
 
Last edited:
I don't think it does, necessarily. The behaviour you're describing is odd though, I haven't played too much with transparent backgrounds on usercontrols but from what I've heard it shouldn't misbehave like this.

One caveat of transparent backgrounds is that only the form background will show through - any other controls between the form and the control will not make a difference. Sorry I can't be more help on this.
 
I found my problem. I was using a technique from this group to keep a background image sized the same as the form. I over-rode the paint method and drew the background image sized to be the correct size.

I dont understand why this caused the problem I was seeing, but if I make the image be the biggest possible size, then it works fine. I would like to use the suggestion to draw the image into a picture box and stretch the image that way, but my picture box ended up on top of all my controls. Is there a way to keep the picture at the bottom of the z order of my panels and controls in my form if I used a picture box instead of the background image on the form?

thanks
Bryan
 
The simplest way would be to make the picturebox the parent of every other control. Failing that, you can right-click on it and select Send to Back to force it to the back of the z-order.
 
Back
Top