
Originally Posted by
Karl77
FONTCOMBO
Small problem
This occurs only if the control is set to RecentMax > 0.
Let's say, the last selected font name was "Zürich".
Then it appears at the top of the list.
If we now press 'End' on the keyboard, the list doesn't scroll down to "Zürich".
It stops at the top, the place where "Zürich" ist found in the recents list.
I would expect that 'End' would go down to the list.
It's not a problem with the control. It's a event problem in connection with the RichTextBox.
The same problem occurs in the Demo.
The reason is that FontCombo1_Click sets the SelFontName of the RichTextBox which on the other hand fires it's own SelChange event and then again sets the Text of the FontCombo.
In order to avoid this circular thing I added in the Demo (RichTextBoxForm.frm) a Freeze boolean flag: (red marked)
Code:
Private Sub FontCombo1_Click()
If FontComboFreezeClick = True Then Exit Sub
RichTextBoxFreezeSelChange = True
If FontCombo1.ListIndex > -1 Then RichTextBox1.SelFontName = FontCombo1.Text
RichTextBoxFreezeSelChange = False
End Sub
Private Sub FontCombo1_CloseUp()
RichTextBox1.SetFocus
End Sub
Private Sub RichTextBox1_SelChange(ByVal SelType As Integer, ByVal SelStart As Long, ByVal SelEnd As Long)
If RichTextBoxFreezeSelChange = True Then Exit Sub
If (SelType And RtfSelTypeText) <> 0 Or SelType = RtfSelTypeEmpty Then
FontComboFreezeClick = True
If IsNull(RichTextBox1.SelFontName) Then
FontCombo1.ListIndex = -1
Else
FontCombo1.Text = RichTextBox1.SelFontName
End If
FontComboFreezeClick = False
End If
End Sub