Results 1 to 5 of 5

Thread: Multiple layered graphics window

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2002
    Posts
    2

    Multiple layered graphics window

    Hello All.

    I am trying to create a usercontrol that has a picturebox on it.

    On top of the picturebox I would like to create a separate transparent usercontrol on which I can draw graphics. The problem is that when I create the "upper layer" usercontrol and set it's backstyle to "transparent", the underlying picture can be viewed, but none of the graphics that I draw on the upper layer foreground are visible.

    It appears that setting the backstyle to opaque is the only way to see my drawn graphics - but this defeats the purpose because the underlying picture can no longer be viewed.

    Is there a way to create a usercontrol that has a transparent background, yet I can draw on the foreground and have the underlying picture show through?

    Thanks, BTT

  2. #2
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    Windows 2K or XP uses layered window styles. Then u can use the API SetLayeredWindowAttributes

  3. #3
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    well just take 2 dcs and blt them ontop of each other on the picturebox that is showing. If you need real transperancy go to www.ur.co.nz there is some nice sample on transperancy (only 8 bit though)
    Sanity is a full time job

    Puh das war harter Stoff!

  4. #4
    Crunchy Cat
    Guest
    Hi, you just need 1 user control to do this. Simply blit the
    background image to the hDc. The foreground image will require
    a little more work. You will actually need two images. The first
    image is called a 'mask'. Just take the original image and ensure
    that the pixels you want displayed are made black (0, 0, 0) and
    the pixels you do not want displayed are made white (255, 255,
    255). Now your mask is complete. Go ahead and modify the
    original image and ensure that all the pixels you DONT want
    displayed are black (0, 0, 0) and the rest remain untouched.
    Now you simply blit the mask with an AND operation on top of
    the background and then blit the slightly modified original image
    with an OR - or - XOR operation and you are done.

    -CC

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2002
    Posts
    2

    Thanks all

    I will give these suggestions a try and see what I come up with. Thanks again.

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