Now we add two comboboxes to the toolbar to change the font and font size of the text in TextDynamic.
Both liat can be initailized in the Lod event of the main form.
Private Sub WordsMDIParent1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
' initialize font size combo
FontSizeSel.Items.Add("6")
FontSizeSel.Items.Add("7")
...
' initialize font name combo
FontNameSel.DropDownStyle = ComboBoxStyle.DropDownList
Dim aFont As FontFamily
For Each aFont In FontFamily.Families
FontNameSel.Items.Add(aFont.Name)
Next
End Sub
To react on a user action we can use the DropDownClosed event. But first we need some code to know which of the child windows is active. The event MdiChildActivate can be used to keep track.
' public variable to represent current TextDynamic editor.
Public WpdllInt1 As WPDynamic.WPDLLInt
Private Sub WordsMDIParent1_MdiChildActivate(
ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.MdiChildActivate
Dim ActiveEditor As WordsChildForm1
ActiveEditor = TryCast(ActiveMdiChild, WordsChildForm1)
If ActiveMdiChild Is Nothing Then
WpdllInt1 = Nothing
Text = "TextDynamicWords"
Else
WpdllInt1 = ActiveEditor.WpdllInt1
' update Caption
Text = "TextDynamicWords [" + ActiveEditor.Text + "]"
End If
End Sub
Now we can implement the OnDropDownClosed code for the font and font size comboboxes. To update the text attributes it is best to use the interface TextAttr since it automatically either changes the attributes of selected text (CurrSellAttr) if there is a selection, or the current writing mode (CurrAttr).