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)

vareditingSession= Xpcom.CreateInstance<nsIEditingSession>("@mozilla.org/editor/editingsession;1");
nsIEditoreditor= 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)

GeckoWebBrowserbrowser= .....;
// Untested codensIHTMLEditorhtmlEditor= (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?"