Results 1 to 19 of 19

Thread: [RESOLVED] Transparent form with borders visible

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Resolved [RESOLVED] Transparent form with borders visible

    Hi, there are hundreds of threads here about making forms transparent, but I can't find any threads that show how to make a form transparent and keep the borders visible.

    Is it possible to do this?


    Using "SetWindowLong" with the borderstyle property set to 1 - 5 doesn't work.
    Last edited by Chris001; May 30th, 2007 at 04:25 PM. Reason: typo

  2. #2
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Transparent form with borders visible

    It's because the border is part of the form. Try searching the forums i think Bushmobile has some samples.

  3. #3
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Transparent form with borders visible

    i did not undestand you question. (may be i am m?d)

    Is this your looking for (pic attached)
    Attached Images Attached Images  

  4. #4
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Transparent form with borders visible

    oh , i guess your talking about TransClusion

  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Transparent form with borders visible

    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  6. #6
    Addicted Member xavierjohn22's Avatar
    Join Date
    Oct 2006
    Location
    Approx. 4921' and 3.11" asl
    Posts
    249

    Re: Transparent form with borders visible

    yeah i remember i experimented one like this, i put a BLUE picture on the form and then make that BLUE the transparent color. Fazi has the declarations on his transparent form.

    Code:
     
     Dim Ret As Long
      Dim CLR As Long
    
      CLR = RGB(0, 0, 255) 'this color is the color that will be transparent
      'Set the window style to 'Layered'
      Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
      Ret = Ret Or WS_EX_LAYERED
      SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
      'Set the opacity of the layered window to 128
      SetLayeredWindowAttributes Me.hWnd, CLR, 0, LWA_COLORKEY

  7. #7
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Talking Re: Transparent form with borders visible

    I am sure what chris wanted is, the form shoud be transclusion (LWA_ALPHA and a value of 128) but not the border of the form.
    I have attached a picture as well as a project.

    The picture shows what Chris wanted.
    The project shows, How to do this using a cheap trick.

    probably there might be ways to do it neetly.
    if there is, forget this cheap trick.
    Attached Images Attached Images  
    Attached Files Attached Files

  8. #8
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Transparent form with borders visible

    @Fazi,
    Nice code. But I need to make some point. Hope you'll not mind.

    1. Your code doesn't have Option Explicit and you've forgotten to add Picture1 in the form. So, it will not compile.

    ALWAYS use Option Explicit.
    ...and when testing for final time, press Ctrl+F5 (run with full compile). That will find any undeclared variable/missing control.

    2. You forgot to unload Form2 when Form1 unloades. So, your program will never end.

    ....also, if you subclass Form1 and move/resize Form2 upon receiving WM_MOVING/WM_WINDOWPOSCHANGING, it will look better.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  9. #9
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Transparent form with borders visible

    Thanks iPrank,

    This is the second time i guess you have pointed out Missing Option Explicit.
    I often make this mistake Prank. Sorry. i should correct this from this minute.

    Ctrl + F5 : Truly i have never use it. Thanks for the Tip.

  10. #10
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Transparent form with borders visible

    You don't need to write option Explicit manually.

    Click Tools>Options... menu.
    In the Editor tab check "Require Variable Declaration".
    Click OK.

    Now whenever you open a new code window, VB will autometically add Option Explicit in your code.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  11. #11
    Member mysql's Avatar
    Join Date
    Mar 2007
    Location
    System Root
    Posts
    42

    Talking Re: Transparent form with borders visible

    Quote Originally Posted by iPrank
    You don't need to write option Explicit manually.

    Click Tools>Options... menu.
    In the Editor tab check "Require Variable Declaration".
    Click OK.

    Now whenever you open a new code window, VB will autometically add Option Explicit in your code.
    Great Tip iPrank. So i will not going to miss 'Option Explicit' after this Thank You.

  12. #12
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Transparent form with borders visible

    You're welcome.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  13. #13
    Banned
    Join Date
    Apr 2006
    Posts
    63

    Re: Transparent form with borders visible

    Quote Originally Posted by iPrank

    Thanks for the info

  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2005
    Posts
    1,834

    Re: Transparent form with borders visible

    Thank you very much, Fazi. That's great!
    Last edited by Chris001; May 31st, 2007 at 04:00 PM.

  15. #15
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Transparent form with borders visible

    Quote Originally Posted by iPrank
    You don't need to write option Explicit manually.

    Click Tools>Options... menu.
    In the Editor tab check "Require Variable Declaration".
    Click OK.

    Now whenever you open a new code window, VB will autometically add Option Explicit in your code.
    Except in the default form's code window when you run VB6, or am I the exception?
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  16. #16
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Transparent form with borders visible

    Quote Originally Posted by Al42
    Except in the default form's code window when you run VB6, or am I the exception?
    It will not add anything to already existing code modules.
    It will work on every NEW code module (form/class/bas module/User control) you add.

    Just close and re-open VB and create a new project. Double click the form and see what happens.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  17. #17
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: [RESOLVED] Transparent form with borders visible

    If I opened VB from a cold start and selected VB Pro Edition Controls, I wouldn't get Option Explicit at the top of Form1's code window. You forced me to do a little research. My Form1 template was damaged. Thanks for forcing me to fix it.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  18. #18
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Talking Re: Transparent form with borders visible

    Quote Originally Posted by Chris001
    Thank you very much, Fazi. That's great!
    Thanks Chris, iPrank and every one

  19. #19
    Banned
    Join Date
    Apr 2006
    Posts
    63

    Re: Transparent form with borders visible

    Quote Originally Posted by Fazi
    Thanks Chris, iPrank and every one



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