Results 1 to 5 of 5

Thread: [RESOLVED] Text fuzzy: Use my Brush for multiLine TextBox

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Resolved [RESOLVED] Text fuzzy: Use my Brush for multiLine TextBox

    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.

    Name:  Cattura.PNG
Views: 371
Size:  27.4 KB

    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 If
    Code:
    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
    Attached Images Attached Images  
    Last edited by Jonney; Feb 1st, 2015 at 09:46 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width