[RESOLVED] VB6 TRANSPARENT background-VBForums
Results 1 to 8 of 8

Thread: [RESOLVED] VB6 TRANSPARENT background

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Posts
    31

    Resolved [RESOLVED] VB6 TRANSPARENT background

    het solved
    Last edited by bim11; Jun 3rd, 2008 at 04:21 PM.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Posts
    31

    Re: VB6 TRANSPARENT background

    anyone know?

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,613

    Re: VB6 TRANSPARENT background

    100% is easy.

    Add any controls you want. For Labels to be transparent set their BackColor to match the one we set the Form to here:
    Code:
    Option Explicit
    
    Private Declare Function GetWindowLong Lib "user32" _
        Alias "GetWindowLongA" ( _
        ByVal hWnd As Long, _
        ByVal nIndex As Long) As Long
    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 SetLayeredWindowAttributes Lib "user32" ( _
        ByVal hWnd As Long, _
        ByVal crKey As Long, _
        ByVal bAlpha As Byte, _
        ByVal dwFlags As Long) As Long
    Private Const GWL_EXSTYLE = (-20)
    Private Const WS_EX_LAYERED = &H80000
    Private Const LWA_COLORKEY = &H1&
    Private Const LWA_ALPHA = &H2&
    
    Private Sub Form_Load()
        'Set the Form transparent by color.
        BackColor = RGB(127, 127, 0) 'Unique but explicit (non-system) color.
        SetWindowLong hWnd, _
                      GWL_EXSTYLE, _
                      GetWindowLong(hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
        SetLayeredWindowAttributes hWnd, BackColor, 0, LWA_COLORKEY
    End Sub

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Posts
    31

    Re: VB6 TRANSPARENT background

    het solved
    Last edited by bim11; Jun 3rd, 2008 at 04:21 PM.

  5. #5
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,430

    Re: VB6 TRANSPARENT background

    Yes I think so, but it won't work on anything less than Win2k. Look up the APIs at MSDN if your unsure.

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,613

    Re: VB6 TRANSPARENT background

    Yes, Win2K and later.

  7. #7
    New Member
    Join Date
    Apr 2004
    Posts
    10

    Re: [RESOLVED] VB6 TRANSPARENT background

    Thanks ... dilettante ... you are ......Great............


    it's not only transparent form , but also .... click- through .


    i tried it on XP .. it works great ........

    Very Great Job

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,613

    Re: [RESOLVED] VB6 TRANSPARENT background

    I got inspired when a guy somewhere else said "only in .Net!"

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.