Handle the WM_CTLCOLORSTATIC
window message in the parent window and return the respective device context handle having a color brush set. Here is an example:
function WinProc(hWnd As HWND, uMsg As UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT
Select Case uMsg
Case WM_CREATE:
warn1 = CreateWindowEx( 0, "STATIC", "", WS_VISIBLE Or WS_CHILD, 20, 150, 300, 40, hWnd, 0, 0, 0 )
SetWindowText( warn1, "WARNING:")
case WM_CTLCOLORSTATIC:
If lParam = warn1 Then
Dim As LRESULT lBrush = DefWindowProc(hWnd, uMsg, wParam, lParam)
SetBkMode(wParam, TRANSPARENT)
'SetBkColor(wParam, BGR(100, 100, 200))
SetTextColor(wParam, BGR(255,0,0))
return lBrush
EndIf
...
End Select
Return DefWindowProc(hWnd, uMsg, wParam, lParam)
End Function