I'm trying to change the text colour of a status bar with no success at all. All I keep getting is 0 returned from the SetTextColor API.
I'm passing in the hwnd of the status bar, and RGB(255,0,0).
Can anybody shed any light?Code:Private Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, _
ByVal crColor As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _
ByVal hdc As Long) As Long
Public Function ChangeTextColourTo(hwnd As Long, lngColour As Long) As Long
'***************************************************************************
'Purpose: Changes the colour of the text for a specified handle.
'Parameters: hwnd - Handle.
' lngColour - Colour to be changed to.
'Returns: The original colour.
'***************************************************************************
On Error GoTo ErrorHandler
Dim hdc As Long
Dim lngOriginalColour As Long
Dim lngReturn As Long
hdc = GetDC(hwnd)
lngOriginalColour = SetTextColor(hdc, lngColour)
lngReturn = ReleaseDC(hwnd, hdc)
ChangeTextColourTo = lngOriginalColour
Procedure_Exit:
Exit Function
ErrorHandler:
Select Case Err.Number
Case Else
GlobalErr Err.Number, Err.Description, "basAPIs - ChangeTextColourTo"
Resume Procedure_Exit
Resume
End Select
End Function
