|
-
Jun 17th, 2002, 02:06 AM
#1
Thread Starter
Junior Member
Transparency Issues with a User Control
I recently created a user control, which basically contains 4 small image fields. I made the background of the control transparent.
The problem is this. Even though the control background is transparent, the areas inside the image boxes (which contain icons with transparency) is the background color of the control (white) This is what it looks like.
I played around with some settings, and made the control windowless. That seemed to work as you can see here
Now, normally I would rejoice, but I found an issue with that. This control is inside a scrolling picture box. When I scroll, the CPU gets maxed out -- so badly that the redraw rate stars to falter. Since I only used one control (anticipating there being 200+ in this scrolling picture box) and got these results, I would hate to see what happens when I get the picture box loaded up. Is there some way I can make the control look like the 2nd picture, but somehow forego the big processor requirement to draw it?
-
Jun 17th, 2002, 05:43 PM
#2
Frenzied Member
Well, you could do something like this... make the control REALLY windowless (so it doesn't show up at all), and do something like this:
VB Code:
Private Sub Picture1_Paint()
YourCustomControl.PaintStuff
End Sub
Now, when that function is called, use VB's PaintPicture function to draw the image to YourCustomControl.Parent (the parent control - Picture1), on the control's coordinates. Or use BitBlt, which is a lot faster than PaintPicture. That's the fastest method I can think of, but you will always have to use some code in the Paint event of the picturebox
-
Jun 17th, 2002, 08:09 PM
#3
Addicted Member
Window transparency does NOT work well in any situation, except for top-level windows. Even in that situation, it's often slow. Especially when scrolling. I suggest 'faking' the transparency by either not using usercontrols (which is a good idea anyway, as each one uses additional GDI, User, and system resources) and painting to the parent picturebox, or virtual-scrolling - use a fixed number of them in the picturebox and change their appearance to fake scrolling.
"1 4m 4 1337 #4xz0r!'
Janus
-
Jun 17th, 2002, 09:21 PM
#4
Thread Starter
Junior Member
Thanks for the advice. I fear I won't be able to make use of it though. The big reason for this is because I need to remove the arrows at any time, if I paint them, removing a single arrow will be pretty tough.
that's why I created the user control. I wanted an actual object I could add and remove, and most importantly one that has custom properties. I guess my only alternative is to just write a whole bunch of code to simulate those 4 arrows found in my control (and the extra properties)
Better than nothing, eh?
Again, thanks for the advice.
-
Jun 19th, 2002, 06:13 PM
#5
Frenzied Member
Heh read my first reply, you can still use the control and the 4 corners thingy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|