Microsoft Visual Basic 6.0: Create Invisible Window
Clear and translucent that a dictionary defines the word transparent. Yes, something that makes transparent clear what is behind him. That's what happens when the application window that is made transparent. Usually the active application window appearance will not overwrite the current window. But now we will try to make a window application with Visual Basic 6.0 so that the transparent inactive windows visible clearly.
How to manufacture the following:
1. Open the Visual Basic 6.0 application via [Start]> [All Programs]> [Microsoft Visual Studio 6.0]> [Microsoft Visual Studio 6.0].
2. In the New Project window, select the New tab.
3. On the New tab, choose Standard EXE and click [Open] to open the window Project1 - Form1 (Form).
4. klik [View] >
- untuk membuka jendela Project1 – Form1 (Code)
-
- 5. Ketikkan kode program berikut ini :
-
- [code]Option Explicit
- 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 Declare Function SetLayeredWindowAttributes Lib "user32" _
- (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Long, ByVal _
- dwFlags As Long) As Long
- Private Const WS_EX_LAYERED As Long = &H80000
- Private Const LWA_ALPHA As Long = &H2
- Private Const GWL_EXSTYLE = (-20)
- Sub TembusPandang(lhWnd As Long, level As Integer)
- On Error GoTo keluar
-
- Call SetWindowLong(lhWnd, GWL_EXSTYLE, GetWindowLong(lhWnd _
- , GWL_EXSTYLE) Or WS_EX_LAYERED)
- Call SetLayeredWindowAttributes(lhWnd, 0, (level * 255) / 100, LWA_ALPHA)
-
- keluar:
- End Sub
-
- Private Sub Form_Load()
- TembusPandang Me.hWnd, 50
- End Sub
In TembusPandang Me.hWnd program code, 50 means the window is made with a transparent level of 50%. Now try changing the numbers 50 to 100. Thus, the effect of invisibility on the window disappeared and returned to normal. Then if we change them to 0, then all the windows are not visible. Please note, translucent effect like this can only be done on the OS Windows 2000 / XP or higher. Good luck!