HtmlEditor :  Phorum 5 The fastest message board... ever.

This is the discussion forum for the HtmlEditor. See also the HtmlEditor home page, where you can download the control, and the Documentation Wiki, a collaborative project for documenting the control.

Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
databinding the html editor
Posted by: PhilS (---.dia.static.qwest.net)
Date: Tuesday, 31-Aug-2010, 16:45:53

Just about managed to get this working.

It seems to be a little fragile in scenarios where the htmleditor is on a tab control, and the tab containing the htmleditor is not the "current tab" when the databinding takes place. I still can't work out a way around the issues with visibility & binding, but here's what i have so far.

public class ChangeMonitor : IHTMLChangeSink
{
private HtmlEditor mHtmlEditor;

public ChangeMonitor(HtmlEditor he) : base()
{
mHtmlEditor = he;
}

public void Notify()
{
mHtmlEditor.InvokeContentChanged();
}
}


and then in the htmleditor.cs:

private void setChangeNotify()
{
//only set this if there is an event handler
if (ContentChanged == null)
{
return;
}
int hr;
this.mChangeMonitor = new ChangeMonitor(this);
hr = ((IMarkupContainer2)this.HtmlDocument2).RegisterForDirtyRange(mChangeMonitor, out changeCookie);
}

and a modification to ReadyStateChangeActions so it looks like this:

internal void ReadyStateChangeActions(IHTMLEventObj o)
{

//defensive - I've known this to be called
//after doc was deactivated
if (this.mHtmlDoc == null) return;
string theReadyState = this.HtmlDocument2.GetReadyState();
if (theReadyState == "complete")
{
//if changed to "COMPLETE", set edit designer

if (this.bLoadDocumentWhenReady)
{
Debug.WriteLine("Now loading doc");
this.LoadDocument(string.Empty);
return;
}
else if (this.bLoadUrlWhenReady)
{
Debug.WriteLine("Now loading url");
this.LoadUrl(this.url);
return;
}
Debug.WriteLine("Setting events");
{
if (this.IsDesignMode)
{
this.SetEditDesigner();
this.execCommand(commandids.IDM_AUTOURLDETECT_MODE, this.mEnableUrlDetection, false, false);
this.setChangeNotify();
}
}
if (this.bSetComposeSettingsWhenReady)
{
this.setDefaultFont();
}
//set HTMLEvents
this.SetHTMLEvents();

//refresh ReadyState since the above actions could have changed it
theReadyState = this.HtmlDocument2.GetReadyState();
}
//invoke ready state changed event
this.InvokeReadyStateChanged(theReadyState);
}



internal void InvokeContentChanged()
{
if (ContentChanged != null)
{
ContentChanged(this, new System.EventArgs());
}
}



Your Name: 
Your Email: 
Subject: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically.
yhUXE
This is a moderated forum. Your message will remain hidden until it has been approved by a moderator or administrator
This forum powered by Phorum.