Hallo
Mit Transparenz und richtiger Höhe.
Option Explicit
Private Declare Function GetDesktopWindow Lib "user32.dll" () As Long
Private Declare Function GetWindowRect Lib "user32.dll" ( _
ByVal hWnd As Long, _
ByRef lpRect As RECT) As Long
Private Declare Function GetDC Lib "user32.dll" ( _
ByVal hWnd As Long) As Long
Private Declare Function InvalidateRect Lib "user32.dll" ( _
ByVal hWnd As Long, lpRect As Any, ByVal bErase As Long) As Long
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As _
Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal _
wFormat As Long) As Long
Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal H As _
Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, _
ByVal I As Long, ByVal U As Long, ByVal S As Long, ByVal C As Long, ByVal OP _
As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As _
String) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal _
hObject As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal _
nIndex As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As _
Long
Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal _
nBkMode As Long) As Long
Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal _
crColor As Long) As Long
Const TRANSPARENT = 1
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function SHAppBarMessage Lib _
"shell32.dll" (ByVal dwMessage As Long, _
pData As APPBARDATA) As Long
Private Type APPBARDATA
cbSize As Long
hWnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long
End Type
Private Function ClearScreen()
ClearScreen = (InvalidateRect(0, 0&, 0) = 1)
End Function
Private Sub Command1_Click()
Dim hWnd As Long
Dim dc As Long
Dim varScreen As RECT
Dim cText As String
Dim oFont As Long
Dim nFont As Long
Dim nH As Long
Dim devY As Long
cText = "Hallo wie geht es Dir?"
hWnd = GetDesktopWindow()
dc = GetDC(0)
GetWindowRect hWnd, varScreen
nH = -((20 * GetDeviceCaps(dc, 90)) / 72)
varScreen.Top = varScreen.Bottom - TaskBarHeight + nH - 5
nFont = CreateFont(nH, 0, 0, 0, 700, 0, 0, 0, 1, 7, 0, 0, 0, "Arial")
oFont = SelectObject(dc, nFont)
SetBkMode dc, TRANSPARENT
SetTextColor dc, vbYellow
DrawText dc, cText, Len(cText), varScreen, 1 + 16 + 512
DeleteObject nFont
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 5000
End Sub
Private Sub Timer1_Timer()
ClearScreen
Timer1.Enabled = False
End Sub
Private Function TaskBarHeight() As Long
Dim AppBar As APPBARDATA
Dim lResult As Long
Const ABM_GETTASKBARPOS = &H5
lResult = SHAppBarMessage(ABM_GETTASKBARPOS, AppBar)
With AppBar.rc
TaskBarHeight = .Bottom - .Top
End With
End Function |