For Single line TextBox or SDK TextBoxW, my customized Brush for textbox works very well. But if the textbox's MultiLine is True, the text got "fuzzy" while I am typing or scrolling.
Code:'In Subclass Procedure,lReturn is my Brush Case WM_CTLCOLOREDIT If TextBoxHandle <> 0 Then If lParam = TextBoxHandle Then Call pvOnCtlColorEdit(wParam, lParam, lReturn) Exit Function 'MSG_BEFORE End If End If Case WM_CTLCOLORSTATIC If TextBoxHandle <> 0 Then If lParam = TextBoxHandle Then Call pvOnCtlColorStatic(wParam, lParam, lReturn) Exit Function 'MSG_BEFORE End If End IfCode:Private Sub pvOnCtlColorEdit( _ ByVal wParam As Long, _ ByVal lParam As Long, _ lReturn As Long _ ) Const TRANSPARENT As Long = 1 If (lParam = TextBoxHandle) Then Call SetTextColor(wParam, TranslateColor(UserControl.ForeColor)) Call SetBkMode(wParam, TRANSPARENT) lReturn = m_hBackBrush End If End Sub Private Sub pvOnCtlColorStatic( _ ByVal wParam As Long, _ ByVal lParam As Long, _ lReturn As Long _ ) Const TRANSPARENT As Long = 1 If (lParam = TextBoxHandle) Then Call SetBkMode(wParam, TRANSPARENT) lReturn = m_hBackBrush End If End Sub Private Sub pvCreateBackBrush() 'Call this before TextBox Creation and Property Let BackColor of UserControl '-- Destroy previous if any If (m_hBackBrush) Then Call DeleteObject(m_hBackBrush) m_hBackBrush = 0 End If '-- Create solid brush m_hBackBrush = CreateSolidBrush(TranslateColor(UserControl.BackColor)) End Sub Public Function TranslateColor(ByVal clrColor As OLE_COLOR, Optional ByRef hPalette As Long = 0) As Long Const CLR_INVALID = -1 If OleTranslateColor(clrColor, hPalette, TranslateColor) Then TranslateColor = CLR_INVALID End If End Function




Reply With Quote