Results 1 to 3 of 3

Thread: picture box cannot be made transparent

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2001
    Location
    Emden, Germany
    Posts
    63

    picture box cannot be made transparent

    I just tried to make a transparent picturebox using SetWindowLongA. It doesn't get transparent! do i make something wrong or is it a bug?
    And if it is a bug, is there any way to make my picturebox transparent then?

    try this code: (add a picturebox, a command-button and something that is hidden beneath the picturebox)

    Const GWL_EXSTYLE = (-20)
    Const WS_EX_TRANSPARENT = &H20&

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

    Private Sub Command1_Click()
    Dim result As Long
    Picture1.ZOrder
    result = SetWindowLong(Picture1.hwnd, GWL_EXSTYLE, _
    WS_EX_TRANSPARENT)
    End Sub

    in MSDN this acutally is reported to be a bug in VB 5.0, but they don't tell about VB6. (and shouldn't they have fixed it in the meantime, if they already knew at the times of VB5 of this bug?) msdn:Q185626

  2. #2
    Megatron
    Guest
    Try:
    Code:
    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 GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Const GWL_EXSTYLE = (-20)
    Private Const WS_EX_TRANSPARENT = &H20&
    
    Private Sub Command1_Click()
        Dim lStyle As Long
        lStyle = GetWindowLong(Picture1.hwnd, GWL_EXSTYLE)
        lStyle = lStyle Or WS_EX_TRANSPARENT
        SetWindowLong Picture1.hwnd, GWL_EXSTYLE, lStyle
    End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2001
    Location
    Emden, Germany
    Posts
    63

    Unhappy no change

    This code also does not work!

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