internal object ExecuteWithUserInterface(int command, object[] arguments) { object[] retVal = new object[] { null }; int hr = CommandTarget.Exec(ref NativeMethods.Guid_MSHTML, command, NativeMethods.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER, arguments, retVal); if (hr != NativeMethods.S_OK) { throw new Exception("Execution of MSHTML command ID \'" + command + "\' failed."); } return(retVal[0]); }
/// <summary> /// Executes the specified command in MSHTML with the specified argument /// </summary> /// <param name="command"></param> protected internal void ExecPrompt(int command) { object[] args = new object[] { null }; //Execute the command int hr = CommandTarget.Exec(ref Interop.Guid_MSHTML, command, Interop.OLECMDEXECOPT.OLECMDEXECOPT_PROMPTUSER, args, null); if (hr != Interop.S_OK) { throw new Exception("MSHTMLHelper.Exec : Command " + command + " did not return S_OK"); } }
/// <summary> /// Executes the specified command in MSHTML and returns the result /// </summary> /// <param name="command"></param> /// <returns>object result - The result of the command</returns> protected internal object ExecResult(int command) { object[] retVal = new object[1]; //Execute the command int hr = CommandTarget.Exec(ref Interop.Guid_MSHTML, command, Interop.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, null, retVal); if (hr != Interop.S_OK) { throw new Exception("MSHTMLHelper.ExecResult : Command " + command + " did not return S_OK"); } return(retVal[0]); }
/// <summary> /// Executes the specified command in this Frame with the specified arguments. /// </summary> /// <param name="command"></param> /// <param name="argument"></param> protected internal void Exec(int command, object argument) { Interop.OLEVARIANT nil = new Interop.OLEVARIANT(); Interop.OLEVARIANT arg = new Interop.OLEVARIANT(); if (argument != null) { switch (argument.GetType().ToString()) { case "System.String": arg.LoadString((string)argument); break; case "System.Boolean": arg.LoadBoolean((bool)argument); break; case "System.Int32": case "System.Int16": arg.LoadInteger((int)argument); break; default: throw new ArgumentException(String.Concat("Unknown Type: ", argument.GetType(), " Argument: ", argument)); } } int hr; try { hr = CommandTarget.Exec(ref Interop.Guid_MSHTML, command, (int)Interop.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, arg, nil); if (hr != Interop.S_OK) { throw new CommandUnavailableException(command, "HtmlEditor.Exec: Command fails. Returncode was: " + hr); } } catch (Exception ex) { throw new CommandUnavailableException(command, "HtmlEditor.Exec: Command fails. See for more details InnerException", ex); } }
/// <summary> /// Overridden to activate design and multiple selection modes /// </summary> /// <param name="args"></param> protected override void OnCreated(EventArgs args) { if (args == null) { throw new ArgumentNullException("You must specify a non-null EventArgs for OnCreated"); } base.OnCreated(args); object[] mshtmlArgs = new object[1]; mshtmlArgs[0] = true; CommandTarget.Exec(ref Interop.Guid_MSHTML, Interop.IDM_PERSISTDEFAULTVALUES, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref Interop.Guid_MSHTML, Interop.IDM_PROTECTMETATAGS, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref Interop.Guid_MSHTML, Interop.IDM_PRESERVEUNDOALWAYS, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref Interop.Guid_MSHTML, Interop.IDM_NOACTIVATENORMALOLECONTROLS, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref Interop.Guid_MSHTML, Interop.IDM_NOACTIVATEDESIGNTIMECONTROLS, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref Interop.Guid_MSHTML, Interop.IDM_NOACTIVATEJAVAAPPLETS, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref Interop.Guid_MSHTML, Interop.IDM_NOFIXUPURLSONPASTE, 0, mshtmlArgs, null); //Set the design mode to the last desired design mode if (_designModeDesired) { DesignModeEnabled = _designModeDesired; _designModeDesired = false; } }
/// <summary> /// Allow editors to perform actions when the MSHTML document is created /// and before it's activated /// </summary> /// <param name="e"></param> protected virtual void OnCreated(EventArgs e) { if (e == null) { throw new ArgumentNullException("You must specify a non-null EventArgs for OnCreated"); } object[] mshtmlArgs = new object[1]; mshtmlArgs[0] = true; CommandTarget.Exec(ref NativeMethods.Guid_MSHTML, NativeMethods.IDM_PERSISTDEFAULTVALUES, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref NativeMethods.Guid_MSHTML, NativeMethods.IDM_PROTECTMETATAGS, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref NativeMethods.Guid_MSHTML, NativeMethods.IDM_PRESERVEUNDOALWAYS, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref NativeMethods.Guid_MSHTML, NativeMethods.IDM_NOACTIVATENORMALOLECONTROLS, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref NativeMethods.Guid_MSHTML, NativeMethods.IDM_NOACTIVATEDESIGNTIMECONTROLS, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref NativeMethods.Guid_MSHTML, NativeMethods.IDM_NOACTIVATEJAVAAPPLETS, 0, mshtmlArgs, null); mshtmlArgs[0] = true; CommandTarget.Exec(ref NativeMethods.Guid_MSHTML, NativeMethods.IDM_NOFIXUPURLSONPASTE, 0, mshtmlArgs, null); // Set the design mode to the last desired design mode if (this.designModeDesired) { this.IsDesignMode = this.designModeDesired; this.designModeDesired = false; } }