Results 1 to 5 of 5

Thread: Transparency Issues with a User Control

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Location
    Meenahsohtah
    Posts
    22

    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?

  2. #2
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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:
    1. Private Sub Picture1_Paint()
    2.     YourCustomControl.PaintStuff
    3. 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
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  3. #3
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221
    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

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2002
    Location
    Meenahsohtah
    Posts
    22
    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.

  5. #5
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    Heh read my first reply, you can still use the control and the 4 corners thingy
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width