Skip to content Skip to sidebar Skip to footer

How To Access NsIHTMLEditor Interface In GeckoFX?

I am trying to make a WYSIWYG HTML-editor by embedding GeckoFX in a Windows Forms application in VB.NET. The code goes like this: Dim Gbrowser As New GeckoWebBrowser Gbrowser.Navig

Solution 1:

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;

Update: The VB code from @GreenBear

Dim gEditor As nsIHTMLEditor: 
gEditor = Gbrowser.Editor: 
gEditor.DecreaseFontSize() 

Post a Comment for "How To Access NsIHTMLEditor Interface In GeckoFX?"