M
Mark Collard
I'm currently writing an application that has a RichTextBox and a toolbar
which includes the following toolbar buttons:
- Font
- Font Size
- Bold
- Italic
- Underline
I want the toolbox buttons to act the same as the ones in Word. i.e. When
you select text that has different Fonts the Font toolbar button (combo box)
is blanked, and when you select text that has different Font Sizes the Font
Size toolbar button (combo box) is blanked.
The RichTextBox control has a property called SelectionFont. The
SelectionFont property returns null if the selected text contains different
fonts, which is fine if I just wanted to update the Font toolbar button
(combo box), but I also want to update the Font Size, Bold, Italic and
Underline buttons. So I looked for an API solution and found that using the
EM_GETCHARFORMAT message with the SendMessage API would return me the
selected Font, Font Size, Bold, Italic and Underline settings, but it doesn't
tell me when multiple Fonts or Font Sizes have been selected. In these cases
it seems to return the Font and Font Size values of where the cursor is in
the RichTextBox.
How can I workout if the selected text in the RichTextBox control contains
multiple fonts, but the same font size?
And how can I workout if the selected text in the RichTextBox control
contains multiple font sizes, but the same font?
Thank you for your help.
which includes the following toolbar buttons:
- Font
- Font Size
- Bold
- Italic
- Underline
I want the toolbox buttons to act the same as the ones in Word. i.e. When
you select text that has different Fonts the Font toolbar button (combo box)
is blanked, and when you select text that has different Font Sizes the Font
Size toolbar button (combo box) is blanked.
The RichTextBox control has a property called SelectionFont. The
SelectionFont property returns null if the selected text contains different
fonts, which is fine if I just wanted to update the Font toolbar button
(combo box), but I also want to update the Font Size, Bold, Italic and
Underline buttons. So I looked for an API solution and found that using the
EM_GETCHARFORMAT message with the SendMessage API would return me the
selected Font, Font Size, Bold, Italic and Underline settings, but it doesn't
tell me when multiple Fonts or Font Sizes have been selected. In these cases
it seems to return the Font and Font Size values of where the cursor is in
the RichTextBox.
How can I workout if the selected text in the RichTextBox control contains
multiple fonts, but the same font size?
And how can I workout if the selected text in the RichTextBox control
contains multiple font sizes, but the same font?
Thank you for your help.