Making any Window Transparent on XP
Intro
This little piece of code written in VB6 allows you to make any window transparent.
Make Firefox, Opera, Internet Explorer, Windows Media Player, Google Talk, Yahoo Messenger, Windows Explorer, basically any window, transparent on Windows XP.
*Transparent Opera
Download
+Zipped binary for Windows XP from here Transp.ZIP [5 KB]
+Source code from planet-source-code
Usage
- Run the Program
- Place the mouse over the title bar of the window which you want to make transparent.
- Now leaving the mouse in the title bar, press the Ctrl button (Normally on the lower right side of the keyboard), now you can see the window name shown in the software.
- Now press the "Set Transparent" Button
- Adjust the Transparency Slider to the required transparency. (Dont set below 100 you will loose sight of the window)
- Press the "Set Opaque" Button to make the window opaque again
- To do for another window repeat the same steps.
Source
Const GWL_EXSTYLE = -20
Const WS_EX_LAYERED = &H80000
Const GWL_STYLE = (-16)
Const WS_VISIBLE = &H10000000
Const LWA_ALPHA = &H2
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Option Explicit
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 Byte, ByVal dwFlags As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
'@ http://digitalpbk.blogspot.com/2007/01/making-any-window-transparent-on-xp.html
Private Type POINTAPI
x As Long
y As Long
End Type
Public xhwnd As Long
Private Sub Command1_Click()
SetWindowLong xhwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes xhwnd, 0, Slider1.Value, LWA_ALPHA
End Sub
Private Sub Command2_Click()
SetWindowLong xhwnd, GWL_EXSTYLE, 0
End Sub
Private Sub Label2_Click()
ShellExecute Me.hwnd, "", "http://digitalpbk.blogspot.com/2007/01/making-any-window-transparent-on-xp.html?ref=EXE", "", "", 1
End Sub
Private Sub Slider1_Change()
SetLayeredWindowAttributes xhwnd, 0, Slider1.Value, LWA_ALPHA 'Change the transparency level
End Sub
Private Sub Timer1_Timer()
Dim xy As POINTAPI
Dim retStr As String * 80
If GetAsyncKeyState(vbKeyControl) Then
Call GetCursorPos&(xy)
xhwnd = WindowFromPoint(xy.x, xy.y)
Call GetWindowText(xhwnd, retStr, 100)
If xhwnd = Me.hwnd Then 'Protect self from being transparent
Label1.Caption = "Making me transparent is not good!"
xhwnd = 0
Else
Label1.Caption = retStr & " " & xy.x & " " & xy.y & " " & xhwnd
End If
End If
End Sub
Anything else?
Lemme know ...leave a comment.