Results 1 to 2 of 2

Thread: Transparent Backgrounds...

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2000
    Posts
    9
    Can someone explain/direct me to a tutorial on how to use a Picture Box, or other control to make an image have a "transparent" background on the form? I have a Shape object displayed on the form, and want an image to partially cover the edge of the Shape. The image is not a regular "boxy" shape, and I need to display the area underneath. Any help would greatly be apreciated.
    Daryl Jones
    Software Developer
    [email protected]

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Hello!
    There are two techniques, the second is much longer and tidious. Try the first against a form. Copy the following to a form and drop two command buttons in.

    ________________________________________________________
    Option Explicit
    Private Const GWL_EXSTYLE = (-20)
    Private Const WS_EX_TRANSPARENT = &H20&
    Private Const SWP_FRAMECHANGED = &H20
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_SHOWME = SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOSIZE
    Private Const HWND_NOTOPMOST = -2

    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

    'The ShowInTaskbar property should be set to False
    Private Sub Command1_Click()
    Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, WS_EX_TRANSPARENT)
    Call SetWindowPos(Me.hwnd, HWND_NOTOPMOST, 0&, 0&, 0&, 0&, SWP_SHOWME)
    End Sub

    Private Sub Command2_Click()
    End
    End Sub
    ________________________________________________________


    What you are looking for is an Api call "Bitblt". Basically, you are going to move the form away, take a picture of the screen and send it to a temporary place. Then you are going to grab a section of that place and stick it into you picture control.
    Chemically Formulated As:
    Dr. Nitro

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