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
| Private Declare Function FindWindow& Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$)
Private Declare Function FindWindowEx& Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1&, ByVal hWnd2& _
, ByVal lpsz1$, ByVal lpsz2$)
Private Declare Function GetDC& Lib "user32" (ByVal hWnd&)
' New color
Private Declare Function GetTextColor& Lib "gdi32" (ByVal hdc&)
Private Declare Function SetTextColor& Lib "gdi32" (ByVal hdc&, ByValcrColor&)
' New police
Private Declare Function CreateFont& Lib "gdi32" Alias _
"CreateFontA" (ByVal nHeight&, ByVal nWidth& _
, ByVal nEscapement&, ByVal nOrientation&, ByVal fnWeight& _
, ByVal fdwItalic As Boolean, ByVal fdwUnderline As Boolean _
, ByVal fdwStrikeOut As Boolean, ByVal fdwCharSet& _
, ByVal fdwOutputPrecision&, ByVal fdwClipPrecision& _
, ByVal fdwQuality&, ByVal fdwPitchAndFamily&, ByVal lpszFace$)
Private Declare Function SelectObject& _
Lib "gdi32" (ByVal hdc&, ByVal hObject&)
Private Declare Function DeleteObject& Lib "gdi32" (ByVal hObject&)
Private Declare Function ReleaseDC& Lib "user32" (ByVal hWnd&, ByVal hdc&)
Sub StatusBarTest()
Dim BarState As Boolean, hWnd&, hdc&, hFont&, hObj&, Color&
BarState = Application.DisplayStatusBar
Application.DisplayStatusBar = True
hWnd = FindWindow(vbNullString, Application.Caption)
hWnd = FindWindowEx(hWnd, ByVal 0&, "EXCEL4", vbNullString)
hdc = GetDC(hWnd)
Color = GetTextColor(hdc)
SetTextColor hdc, RGB(255, 0, 0)
hFont = CreateFont(-12, 0, 0, 0, 700, 1, 1, 0, 0, 0, 0, 0, 0, "Times NewRoman ")
hObj = SelectObject(hdc, hFont)
Application.StatusBar = " Voici une nouvelle couleur pour la StatusBar !"
MsgBox "Qu'en pensez-vous ?", 64
Application.StatusBar = False
SelectObject hdc, hObj
DeleteObject hFont
SetTextColor hdc, Color
ReleaseDC hWnd, hdc
Application.DisplayStatusBar = BarState
End Sub |
Partager