Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

VB 6.0: Tutorial, How to Make Glass2K!!


  • Please log in to reply
19 replies to this topic

#1 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 21 August 2006 - 02:48 AM

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)

Windows 2000/XP ( because Transparency will not work in other Win 95,98,ME and so! )
So open VB and the following will be shown:-

Posted Image

Select Standard EXE and Press Open.
You will be presented an empty Form.
Ok so now add a module. How? see the pic below:-

Posted Image

The following will be displayed:-

Posted Image

Now Press Open.
and paste the following code into the module:-

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


This code is a Function to make a window Transparent
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:-

Posted Image

Now all we need to do is adding the following code to our project:-

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

Explaining the code:-
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Here we are declaring an API function to Find a Windows from the title bar

    Dim Handle As Long
Here we are just declaring a Variable

    Handle = FindWindow(vbNullString, Text1.Text)
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.

    MakeTransparent Handle, 100
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.
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

Attached Files


  • 0

#2 Crane

Crane

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 388 posts

Posted 21 August 2006 - 04:30 AM

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.
  • 0

#3 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 21 August 2006 - 05:05 AM

Ow thanks :) well 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!!
  • 0

#4 Lop

Lop

    Speaks fluent binary

  • Just Joined
  • PipPipPipPipPipPipPip
  • 1112 posts

Posted 22 August 2006 - 05:00 AM

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!
  • 0

#5 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 22 August 2006 - 05:02 AM

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!!
  • 0

#6 Gabeli

Gabeli

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 12 February 2008 - 09:50 AM

Thnx buddy
  • 0

#7 Dj-York

Dj-York

    CC Lurker

  • Just Joined
  • Pip
  • 7 posts

Posted 30 March 2008 - 08:54 AM

Nice tutorial and THX !
  • 0

#8 JustSimple

JustSimple

    CC Lurker

  • Just Joined
  • Pip
  • 7 posts

Posted 30 March 2008 - 12:01 PM

Thanks... :)
  • 0

#9 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 30 March 2008 - 02:53 PM

Welcome. Hope this helps you in learning VB as you said in your intro
  • 0

#10 Bigjohn123

Bigjohn123

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 01 June 2008 - 05:14 AM

Glass2k does work with Vista 32-bit Home Premium, that's what I am using right now.
  • 0

#11 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 01 June 2008 - 11:13 AM

I'm on vista right now, but VB is not installed because I formatted a few days ago. Does it display any error?
  • 0

#12 Guest_Kaabi_*

Guest_Kaabi_*
  • Guest

Posted 02 June 2008 - 11:08 AM

I'm not familiar with Glass2K but it sounds advanced.
  • 0