Well I don't know if you people use Glass2k, Well I used it some time ago, but then I decided to make my own! Well in this tutorial I will show you how to make the basics of Glass2k not the whole app.
Requirements:-
- Visual Basic (prefiribly 6.0)
So open VB and the following will be shown:-
- Windows 2000/XP ( because Transparency will not work in other Win 95,98,ME and so! )
Select Standard EXE and Press Open.
You will be presented an empty Form.
Ok so now add a module. How? see the pic below:-
The following will be displayed:-
Now Press Open.
and paste the following code into the module:-
This code is a Function to make a window TransparentCode:Option Explicit 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 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 Const GWL_EXSTYLE = (-20) Private Const LWA_ALPHA = &H2 Private Const ULW_ALPHA = &H2 Private Const WS_EX_LAYERED = &H80000 Public Function MakeTransparent(ByVal hwnd As Long, Perc As Integer) As Long Dim Msg As Long On Error Resume Next If Perc < 0 Or Perc > 255 Then MakeTransparent = 1 Else Msg = GetWindowLong(hwnd, GWL_EXSTYLE) Msg = Msg Or WS_EX_LAYERED SetWindowLong hwnd, GWL_EXSTYLE, Msg SetLayeredWindowAttributes hwnd, 0, Perc, LWA_ALPHA MakeTransparent = 0 End If If Err Then MakeTransparent = 2 End If End Function
Ok so now what?
Now Add a Textbox ( Text1 ) and a Command Button ( Command1 )
and arrange the form the way you like I made it as follows:-
Now all we need to do is adding the following code to our project:-
Explaining the code:-Code:Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub Command1_Click() Dim Handle As Long, Ret As Long Handle = FindWindow(vbNullString, Text1.Text) MakeTransparent Handle, 100 End Sub
Here we are declaring an API function to Find a Windows from the title barCode:Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Here we are just declaring a VariableCode:Dim Handle As Long
Here we are assigning the variable with the API to find the window with the title bar same as the textbox ( text1 ) text that we added on out form.Code:Handle = FindWindow(vbNullString, Text1.Text)
Here we are calling the Function of the module to make transparent the Var Handle, that we assigned to it the window, and 100 is the transparency level you want ex.Code:MakeTransparent Handle, 100
250 is solid ( normal window colour )
1 is invisible ( makes the wnidow invisible )
and the larger the no ( max 250 ) the more visible will the window be but still transparent until it is 250 ) so from 100 to 200 is the ideal value for a transparent window
Now how does this work?
Well run your app and open for example My Documents and in the Textbox write My Documents and then press the command button and the My Documents window will be transparent. Now to restore the window to its original color just close My Documents and Re-open it!
I want to make Transparent another window instead of My Documents, how?
Simple just type in the title of the window in the Textbox and press the command button!
Complete Source Code:-
Well I included the FULL source code its an attachment, its the complete project just compile and have fun
Ending:-
If you have any questions/problems/feedback pls post here and I will sureley Help you! Well this will make you only the selected window transparent not exactly like Glass2k but if you modify it you surely can make it
So I'm waiting for your feedback
Ow and if you want me to make you some tutorials request what you want and I will see what I can do! I will be happy making some tuts here!
Tcm9669
Last edited by Jordan; 10-02-2006 at 09:45 AM. Reason: Picture Location Change
Wow! Nice tutorial! I'd like to see more like this in the future. How did you include the images in your post like that? I'm thinking of creating my own tutorial.
Ow thankswell its simple to make the pics like that upload the image on imageshack.us and then select the link of Forums copy and paste that link
it should have [IMG] link [IMG] ow ant the most imgs you can post here in a post is 4 or 5 ( its a restriction of the Admin ) but then you can post the others as a normal link!
Come on ppl more feedback pls! my 2nd tut is on the way! will be posted shortly !! its nice helping ppl and seeing good feedback!!
Nice tutorial! I'd love to see more like this. I wasn't aware there was a limit on the pictures though. hmm.
I think I'm going to create a few, you have inspired me!
LOL! What tuts you are going to make? VB, Java? What?
Im curious!
Ow and btw there is another tutorial pls comment on it! and I have another tutorial on the way!!
Thnx buddy
Nice tutorial and THX !
Thanks...![]()
Welcome. Hope this helps you in learning VB as you said in your intro
Glass2k does work with Vista 32-bit Home Premium, that's what I am using right now.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks