Condividi tramite


IDM_COMPOSESETTINGS Command ID

Sets the default composition font settings for the MSHTML Editor.

C++ Information

Command group CGID_MSHTML (defined in mshtmhst.h)
Symbolic constant IDM_COMPOSESETTINGS
User interface None. Set nCmdExecOpt to OLECMDEXECOPT_DONTPROMPTUSER.
IOleCommandTarget::Exec parameters
pvaInVARIANT of type VT_BSTR that specifies a comma-delimited list of font property values in the following order:
  • Bold: 1 for bold; 0 or blank for non-bold.
  • Italic: 1 for italic; 0 or blank for non-italic.
  • Underline: 1 for underline; 0 or blank for non-underline.
  • Size: Integer that specifies the font size within a range of 1 through 7, with 7 representing the largest font.
  • Font Color: RGB color value given by a period-delimited list of three integers (for example, 100.19.0). Each number should be between 0 and 255, but if a number is not, the value for the color will be interpreted as the number mod 255.
  • Background Color: RGB color value given by a period delimited list of three integers (such as 100.19.0). Each number should be between 0 and 255, but if a number is not, the value for the color will be the number mod 255.
  • Name: String that specifies a font name.
pvaOut Set to NULL.
Header file mshtmcid.h
Applies to IHTMLDocument2::execCommand, IHTMLDocument2::queryCommandEnabled, IHTMLDocument2::queryCommandIndeterm, IHTMLDocument2::queryCommandState, IHTMLDocument2::queryCommandSupported, IHTMLDocument2::queryCommandValue, IOleCommandTarget::Exec, IOleCommandTarget::QueryStatus.

Remarks

The command IDM_HTMLEDITMODE must be issued before issuing this command; otherwise, IDM_COMPOSESETTINGS will have no effect.

Default composition font settings apply only to editable documents or regions within documents. The default composition font settings affect blank lines and new paragraphs. If a context exists for determining font properties (for example, when the caret is positioned in the middle of an existing line), the context will determine font properties. The default composition font is Times New Roman.

Blank values for any of the comma-delimited parameters cause the font property value to revert to its default.

Example

This example shows how to change the Editor's default composition font to the largest-size italic green Comic Sans MS. Notice that unused fields in the comma-separated list are left blank.


// Enable compose settings with IDM_HTMLEDITMODE
VARIANT varIn;
varIn.vt = VT_BOOL;
varIn.boolVal = TRUE;
 
pCommandTarget->Exec(&CGID_MSHTML,
                     IDM_HTMLEDITMODE,
                     MSOCMDEXECOPT_DONTPROMPTUSER,
                     &varIn,
                     NULL);

// Set IDM_Compose Settings:  
varIn.vt = VT_BSTR;
varIn.bstrVal = SysAllocString(L",1,,7,0.255.0,,Comic Sans MS");

pCommandTarget->Exec(&CGID_MSHTML,
                     IDM_COMPOSESETTINGS,
                     MSOCMDEXECOPT_DONTPROMPTUSER,
                     &varIn,
                     NULL);

SysFreeString(varIn.bstrVal);

Minimum Availability

Internet Explorer 5.5 and later.