public static void ExecuteCommandHtmlDoc(IHTMLDocument2 htmlDoc, HtmlCommand command, object data) { try { if (htmlDoc.IsNull()) { return; } // ensure command is valid and enabled if (!htmlDoc.queryCommandSupported(command.Name())) { return; } if (!htmlDoc.queryCommandEnabled(command.Name())) { return; } htmlDoc.execCommand(command.Name(), false, data); } catch (RemotingException) { } catch (UnauthorizedAccessException) { } }
public static object QueryValueHtmlDoc(IHTMLDocument2 htmlDoc, HtmlCommand command) { try { if (htmlDoc.IsNull()) { return(null); } // ensure command is valid and enabled if (!htmlDoc.queryCommandSupported(command.Name())) { return(null); } if (!htmlDoc.queryCommandEnabled(command.Name())) { return(null); } return(htmlDoc.queryCommandValue(command.Name())); } catch (RemotingException) { } catch (UnauthorizedAccessException) { } return(null); }
/// <summary> /// Executes the execCommand on the selected document. /// Only affects the currently selected range. /// </summary> public static void ExecuteCommand(HtmlCommand command, object data) { var htmlDoc = ContentUtils.GetFocusedHtmlDoc(); if (!htmlDoc.IsNull()) { ExecuteCommandHtmlDoc(htmlDoc, command, data); } }
public static object ExecuteQuery(HtmlCommand command) { var htmlDoc = ContentUtils.GetFocusedHtmlDoc(); if (!htmlDoc.IsNull()) { return(QueryValueHtmlDoc(htmlDoc, command)); } return(null); }