Results 1 to 7 of 7

Thread: Transparent Picturebox / Image with a handle...

  1. #1

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205

    Transparent Picturebox / Image with a handle...

    I want to display a picture over all my other controls, but with a transparent background.

    The PictureBox doesn't have a bloody transparency, and the Image control won't show in front of certain controls...


    Point me in the right direction someone...
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    how about transparent bitblt? will that work?
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  3. #3

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Potentially. Show me how, and I'll let you know...
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  4. #4
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    this is apiguide example:

    VB Code:
    1. 'This project needs 2 pictureboxes
    2. 'Picturebox1 must contain a picture with a lot of white pixels (we're going to use white as transparent color)
    3. Private Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean
    4. Private Sub Form_Load()
    5.     'KPD-Team 1999
    6.     'URL: [url]http://www.allapi.net/[/url]
    7.     'E-Mail: [email][email protected][/email]
    8.     Picture1.AutoSize = True
    9.     'API uses pixels
    10.     Picture1.ScaleMode = vbPixels
    11.     Picture2.ScaleMode = vbPixels
    12. End Sub
    13. Private Sub Picture2_Paint()
    14.     'If we don't call DoEvents first, our transparent image will be completely wrong
    15.     DoEvents
    16.     TransparentBlt Picture2.hdc, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, Picture1.hdc, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, vbWhite
    17. End Sub
    Requires Windows 2000 or later; Requires Windows 98 or later
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  5. #5

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Apparently I don't have msimg32.dll on this machine (NT4 workstation).

    Any other ideas?
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  6. #6
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    well... i don't know how to do this, but you could use bitblt with a mask. maybe search forum.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  7. #7

    Thread Starter
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    Yeah, been doing that... I don't want to use a mask and BitBlt if I can find a more flexible way. Don't want 2 pictures for every transparent image I want... stoopid vb designers... :grrr:
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

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