Overcoat combobox using WndProc

I overtook WndProc from ComboBox and I draw my own combo box, a snapshot of the code below:

Protected Overrides Sub WndProc(ByRef m As Message)

    MyBase.WndProc(m)
    Select Case m.Msg
        Case &HF

            Dim g As Graphics = Me.CreateGraphics

            If ComboBoxRenderer.IsSupported Then
                Dim pTextBoxRect As New Rectangle(Me.ClientRectangle.X, Me.ClientRectangle.Y, Me.ClientRectangle.Width, Me.ClientRectangle.Height)
                ComboBoxRenderer.DrawTextBox(g, pTextBoxRect, _tbState)
                 ' .... and so on
    End Select
End Sub

Although the old control is still painted, as my drawn combo box just overlaps the old drawing. Is there a way to stop it when creating a default combo box?

Thanks Rob

+3
source share
1 answer

The method you use is the only way to do this, but you're right, it draws the top of the default drop-down list, while still using the combobox control.

- combobox, , combobox.

+2

Source: https://habr.com/ru/post/1709176/


All Articles