[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.
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.
1 Attachment(s)
Re: Transparent form with borders visible
i did not undestand you question. (may be i am m?d) :D
Is this your looking for (pic attached)
Re: Transparent form with borders visible
oh , i guess your talking about TransClusion :D
Re: Transparent form with borders visible
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
2 Attachment(s)
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. :D
if there is, forget this cheap trick. :wave:
Re: Transparent form with borders visible
@Fazi,
Nice code. :thumb: 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. :)
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.
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.
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:wave: Thank You.
Re: Transparent form with borders visible
Re: Transparent form with borders visible
Quote:
Originally Posted by iPrank
Thanks for the info :)
Re: Transparent form with borders visible
Thank you very much, Fazi. That's great! :thumb:
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?
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. ;)
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.
Re: Transparent form with borders visible
Quote:
Originally Posted by Chris001
Thank you very much, Fazi. That's great! :thumb:
Thanks Chris, iPrank :blush: and every one :wave:
Re: Transparent form with borders visible
Quote:
Originally Posted by Fazi
Thanks Chris, iPrank :blush: and every one :wave:
:wave: