0

I am using an HTML editing control build on MS HTML.

I need to be able to force text to be bold/unbold and cannot find an easy way to do this.

I can toggle bold status as follows:

(D as IHTMLDocument2).execCommand('Bold', False, EmptyParam);

I can get bold status as follows:

bIsBold := (D as IHTMLDocument2).queryCommandValue('Bold');

Now of course you will say, well duh, just get the bold status and then toggle it if you need to.

Unfortunately the selected text can actually have three states: not bold/partially bolded/all bold, so i am forced to blindly toggle the status before querying it to ensure it is only in the two know states: not bold/all bold. This is quite ugly so i would like to know if i am missing something obvious.

Thanks IA

Zax
  • 471
  • 1
  • 4
  • 14
  • Could you not query whether the first character is or is not bold? And toggle the entire text accordingly? In case of zero length noop. – Joop Eggen Feb 07 '12 at 00:44
  • Sorry Joop, I'm not following. Querying the first character would still only give me to two states, "not bold" or "all bold". I would still be unaware if it was in the "partially bold" state. – Zax Feb 08 '12 at 00:37

1 Answers1

0

Yes, but pressing the bold switch would then function expectedly (if one knows). Like in other editors.

Joop Eggen
  • 107,315
  • 7
  • 83
  • 138
  • Yes, I am satisfied with the way my Bold button works, but what i want to do is copy style from one location to another (i.e. format painting). This requires having a reliable method for emboldening an item (as well as underlining, italicizing, etc). – Zax Feb 08 '12 at 20:36
  • Okay, I know no solution for that. – Joop Eggen Feb 09 '12 at 07:39