1

I am using Gecko browser in my program. I am trying to turn on design mode on this browser like that:

webBrowser1.Document.DomDocument.GetType().GetProperty("designMode").SetValue
(webBrowser1.Document.DomDocument, "On", null);

But it doesn't works. How can I do it?

  • Possible duplicate of [How to access nsIHTMLEditor interface in GeckoFX?](https://stackoverflow.com/questions/33467992/how-to-access-nsihtmleditor-interface-in-geckofx) – Bartosz Jun 11 '17 at 07:44

1 Answers1

0

nsIHTMLEditor is likely a per browser instance rather than a global instance (like things returned by Xpcom.GetService)

One can get a nsIEditor like this by (by supplying a Window instance)

var editingSession = Xpcom.CreateInstance<nsIEditingSession>("@mozilla.org/editor/editingsession;1");
nsIEditor editor = editingSession.GetEditorForWindow((nsIDOMWindow)Window.DomWindow);
Marshal.ReleaseComObject(editingSession);

(or you can just call the nsIEditor GeckoWebBrowser.Editor property.)

You may be able to cast this nsIEditor to a nsIHtmlEditor (although I have yet to try it)

GeckoWebBrowser browser = .....;
// Untested code
nsIHTMLEditor htmlEditor = (nsIHTMLEditor)browser.Editor;

The VB code from @GreenBear

Dim gEditor As nsIHTMLEditor: 
gEditor = Gbrowser.Editor: 
gEditor.DecreaseFontSize() 
Robert Williams
  • 1,370
  • 1
  • 17
  • 38