Results 1 to 5 of 5

Thread: [RESOLVED] Fully Transparent form

Hybrid View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    107

    Resolved [RESOLVED] Fully Transparent form

    hi VB Forums
    i have vb code for making a form transparent, but that code has got 1 problem- it with that code if u click in the form area it takes click to the window behind that form
    here's the code im using:
    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
    so i want my form fully trans-parent but dont want any interactions with window behind it.....

    if anybody have code then please post it here.

    Thank you
    Boing

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Fully Transparent form

    If you are telling the O/S to make it transparent, it will click thru. Recommend trying the following modification. It is 99.9% transparent.
    SetLayeredWindowAttributes hWnd, 0&, 1, LWA_ALPHA

    FYI: This could be really annoying for someone if you lose track of the form or make it maximized. It's not visible, it may be overlapping other windows, the user can't click thru to them and has no idea why. Maybe you have more pure intentions.

    Edited: Really no reason to assign a unique backcolor now. You just may want to make the form's backcolor white or black.
    Last edited by LaVolpe; Aug 19th, 2009 at 08:13 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    107

    Re: Fully Transparent form

    thank you very much LaVolpe, in actual i wanna give my program a cool effect by transperacy and also change activate the timer on click anywhere in the form, its smilar to poerpoint type presentation in which image will scroll on clicking anywhere...

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [RESOLVED] Fully Transparent form

    I don't know if the above will work you giving your description, unless you plan on putting your animation under the transparent window. If the window is 99.9% transparent, so is any graphics on that window.

    I actually used similar code to create a software screen filter/tinter. My wife complained the screen hurt her eyes, especially at night. So I used semi-transparency, with color options. Now she can choose the level of opacity and which color to overlap the entire screen. The big difference is the my project had to remain click-thru, so to close the screen filter or change options, a system tray icon is used.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    107

    Re: [RESOLVED] Fully Transparent form

    i will use multiple forms for that..

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