Force bold with IHTMLDocument

324 views Asked by At

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

1

There are 1 answers

2
Joop Eggen On

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