Rubrik: System/Windows · Desktop/Bildschirm/Display | VB-Versionen: VB4, VB5, VB6 | 30.07.03 |
Transparente Taskleiste Wie lässt sich die Windows-Taskleiste transparent machen? Hier die Lösung. | ||
Autor: --Florian-- | Bewertung: | Views: 17.269 |
t-g-f.de | System: Win2k, WinXP, Win7, Win8, Win10, Win11 | Beispielprojekt auf CD |
Wie lässt sich die Windows-Taskleiste transparent machen?
Nachfolgend die Lösung.
Option Explicit ' Benötigte API-Deklarationen Private Declare Function SetLayeredWindowAttributes Lib "user32" ( _ ByVal hwnd As Long, _ ByVal crey As Byte, _ ByVal bAlpha As Byte, _ ByVal dwFlags As Long) As Long Private Declare Function FindWindow Lib "user32.dll" _ Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) 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 WS_EX_LAYERED = &H80000 Private Const LWA_ALPHA = &H2
Public Sub Taskbar_Transparent_Level( _ ByVal bLevel As Byte) Dim lOldStyle As Long Dim LhWnd As Long ' Fensterhandle ermitteln LhWnd = FindWindow("Shell_TrayWnd", vbNullString) If (LhWnd <> 0) Then lOldStyle = GetWindowLong(LhWnd, GWL_EXSTYLE) SetWindowLong LhWnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED SetLayeredWindowAttributes LhWnd, 0, bLevel, LWA_ALPHA End If LhWnd = FindWindow("BaseBar", vbNullString) If (LhWnd <> 0) Then lOldStyle = GetWindowLong(LhWnd, GWL_EXSTYLE) SetWindowLong LhWnd, GWL_EXSTYLE, lOldStyle Or WS_EX_LAYERED SetLayeredWindowAttributes LhWnd, 0, bLevel, LWA_ALPHA End If End Sub
Der Aufruf erfolgt dann so:
' Taskbar transparent machen Taskbar_Transparent_Level 100
' Taskbar wieder normal darstellen Taskbar_Transparent_Level 255
Wie Sie unschwer erkennen können, lässt sich die Intensität über den Parameter bLevel angeben. 0 bedeutet hierbei völlig unsichtbar, wohingegen der Wert 255 keine Transparenz bedeutet.