1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| Public Function DrawGlowingText(ByVal hDC As IntPtr, ByVal Text As String, ByVal Font As Font, ByVal Color As Color, ByVal Rect As Rectangle, ByVal GlowSize As Integer) As Integer Dim hTheme As Integer = OpenThemeData(GetDesktopWindow, "TextStyle") If hTheme > 0 Then Dim dib As New BITMAPINFO Dim dto As New DTTOPTS Dim hMemDC As Integer = CreateCompatibleDC(hDC)
With dib.bmiHeader .biSize = 40 .biWidth = Rect.Width * 40 .biHeight = -Rect.Height * Font.Size .biPlanes = 1 .biBitCount = 32 .biCompression = BI_RGB End With
With dto .dwSize = Len(dto) .dwFlags = DTT_GLOWSIZE Or DTT_COMPOSITED Or DTT_TEXTCOLOR .iGlowSize = GlowSize .crText = ARGB2RGB(Color) End With
Font = New Font(Font.FontFamily.Name, Font.Size)
Dim hDIB As Integer = CreateDIBSection(hDC, dib, DIB_RGB_COLORS, 0, 0, 0) Dim hObjectOld As Integer = SelectObject(hMemDC, hDIB) SelectObject(hMemDC, Font.ToHfont()) Rect.X = Rect.X + GlowSize
DrawThemeTextEx(hTheme, hMemDC, 0, 0, Text, -1, 0, Rect, dto) BitBlt(hDC, Rect.Top, Rect.Left, Rect.Width, Rect.Height, hMemDC, 0, 0, SRCCOPY)
SelectObject(hMemDC, hObjectOld)
DeleteObject(hDIB) DeleteDC(hMemDC) CloseThemeData(hTheme) Return 0 Else Return GetLastError() End If End Function
|