简体   繁体   中英

Force bold with IHTMLDocument

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM