borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2009 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (How can i know the header of a file)Next Topic (Find File) New Topic New Poll Post Reply
AndreaVB Forum : VB General : How to set your form semi-transparent
Poster Message
noycez
Level: VB Guru


Registered: 14-10-2002
Posts: 79

icon How to set your form semi-transparent

Private Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hwnd As Long, ByVal
crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Boolean

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
Const LWA_ALPHA = 2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000

Private Sub Form_Load()
    SetWindowLong hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
    SetLayeredWindowAttributes hwnd, 0, 128, LWA_ALPHA
End Sub

  

____________________________
Funny thought:

Practice makes perfect.....
But nobody's perfect......
so why practice?

11-11-2002 at 06:08 AM
View Profile Send Email to User Show All Posts | Quote Reply
dfanning
Level: Guest

icon Re: How to set your form semi-transparent

Very cool...
can't think of a "practical" purpose yet... but I've been meaning to insert an easter egg...

11-11-2002 at 03:07 PM
| Quote Reply
mjhendryx
Level: Guest

icon Re: How to set your form semi-transparent

That code is pretty slick noycez!


What about applying only to specific objects in the VB Application?  Is this even possible?

I understand the "visible" true/false toggle to remove specific objects from view.  I'm primarily interested in partial transparency.  

Please Advise.

thanks in advance
MJH

01-04-2003 at 07:22 PM
| Quote Reply
mjhendryx
Level: Guest

icon Re: How to set your form semi-transparent

I'm realitvely new to programming.  

What about user control over level of transparency?  You use constants to define the level of transparency (I'm guessing thats what those constants are used for).  I tried to set them to dynamic variables attached to some scroll bars so I could change the level of transparency but nothing happens and its not even transparent anymore?

(I'm using VB6 on a Win2K professional OS)

01-04-2003 at 07:43 PM
| Quote Reply
AndreaVB Forum : VB General : How to set your form semi-transparent
Previous Topic (How can i know the header of a file)Next Topic (Find File) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2009 Andrea Tincaniborder