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
Go to Page: Previous123Next
Current Page: 2 of 3
Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: kannan chandrasekaran (203.124.157.---)
Date: Wednesday, 01-Dec-2004, 07:32:43

hi Tom

Fine thanks for ur reply.

but still i am not able to implement. because
the following declarations are not available for me

1) private BaseEditor _owner;

2) this._dropTarget in getdroptarget method.

expecting ur help

thanks

kannan.c

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: kannan chandrasekaran (203.124.157.---)
Date: Wednesday, 01-Dec-2004, 08:16:06

also

this._parent in getdropTarget method

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: kanvishok (203.124.157.---)
Date: Wednesday, 01-Dec-2004, 11:03:04

How can i trigger these events.

i just return the interface in my comsuport.cs like the following.


[System.Runtime.InteropServices.ComImport()]
[System.Runtime.InteropServices.InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
[System.Runtime.InteropServices.GuidAttribute("00000122-0000-0000-C000-000000000046")]
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public interface IOleDropTarget
{
#region Methods
[System.Runtime.InteropServices.PreserveSig()] int OleDragEnter (IntPtr pDataObj, [System.Runtime.InteropServices.MarshalAs(UnmanagedType.U4)] int grfKeyState, [System.Runtime.InteropServices.MarshalAs(UnmanagedType.U8)] long pt, ref int pdwEffect);
[System.Runtime.InteropServices.PreserveSig()] int OleDragOver (int grfKeyState, [System.Runtime.InteropServices.MarshalAs(UnmanagedType.Struct)] mshtml.tagPOINT pt, ref int pdwEffect);
[System.Runtime.InteropServices.PreserveSig()] int OleDragLeave ();
[System.Runtime.InteropServices.PreserveSig()] int OleDrop (IntPtr pDataObj, [System.Runtime.InteropServices.MarshalAs(UnmanagedType.U4)] int grfKeyState, [System.Runtime.InteropServices.MarshalAs(UnmanagedType.Struct)] mshtml.tagPOINT pt, ref int pdwEffect);
#endregion
}


after that i implement these methods in my htmlsite.cs. but
OleDragEnter ,oleDrageOver, OleDrop none of the events were triggered.

how can i trigger these events

thanks

kannan.c

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: Tomcat (203.91.158.---)
Date: Friday, 03-Dec-2004, 10:46:17

hi !
1. remove all code and references to the BaseEditor _owner variable from the implementation or Replace the private BaseEditor _owner with private HtmlEditor _owner both in constructor and in the declaration section.

2. this._dropTarget is a variable of IOleDropTarget type , define it in MshtmlSite implementation if not already defined.

3. this._parent is the control on which MshtmlSite is hosted (HtmlEditor)
the the code as for HtmlEditor

public int GetDropTarget( ComInterop.IOleDropTarget pDropTarget,out ComInterop.IOleDropTarget ppDropTarget)
{
HtmlEditor theHtmlEditor;
DragLoadConverter theDataObjectConverter;
if (this._dropTarget == null)
{
theHtmlEditor = (this.container as HtmlEditor);
if (theHtmlEditor != null)
{
theDataObjectConverter = theHtmlEditor.DataObjectConverter;
if (theDataObjectConverter != null)
{
this._dropTarget = new DropTarget(theHtmlEditor,theDataObjectConverter, pDropTarget);
}
}
}

p.s.
sorry for my poor english

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: James Hancock (209.112.24.---)
Date: Friday, 10-Dec-2004, 20:09:50

FYI for everyone. I'm almost done implimenting in my version, full drag and drop that exposes everything as .net objects and fires the .net events.

I'll post a new version when it's done.

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: James Hancock (209.112.24.---)
Date: Friday, 10-Dec-2004, 20:40:36

Ok, road block.

Unfortunately, I figured I could just use the IDataObject defined in System.windows.forms, but unfortunately I can't, so I'm having trouble rasing the Drag/drop events in .net

Anyone have an idea how to create a new System.Windows.Forms.IDataObject and convert the standard implimentation to it?

Once that's done, then all of the drag/drop stuff will work in .net.

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: James Hancock (209.112.24.---)
Date: Friday, 10-Dec-2004, 20:54:05

(Yes I know that some of the above is about that, but it's just not clear at all, and it appears that it hasn't actually been implimented yet)

I just need to figure out how to use the .GetData function on the pDataObj and I'm set.

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: nabil (202.69.45.---)
Date: Friday, 14-Jan-2005, 11:00:20

hi ,
I have read all these notes, actually I am facing the same problem , I want to restrict the drag drop in my MSHTML WebBrowser , if I some starts to drag an Element in the Editor and drops in the Editor it should not work , so wat I want is an editor which doesnot support Drag and Drop of elements . I have implemented IHTMLEditHost Interface it is working with the Absouute images why it is not working for other type of Images

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: James Hancock (---.amtelecom.net)
Date: Friday, 14-Jan-2005, 16:27:50

Anyone have any code to convert the IDataObject that is implimented above to the .net version?

If someone can post some code to do that, then we're set and Drag and Drop becomes purely a .net endevour.

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: Tomcat (---.dsl.net.pk)
Date: Tuesday, 18-Jan-2005, 05:21:42

public int OleDrop (IntPtr pDataObj, int grfKeyState, mshtml.tagPOINT pt, ref int pdwEffect)
{
System.Windows.Forms.DataObject theDataObject;
theObject = Marshal.GetObjectForIUnknown (pDataObj);
theDataObject = new DataObject (theObject);
}

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: James Hancock (209.112.24.---)
Date: Friday, 28-Jan-2005, 15:03:59

Thanks! Next UberBuild will have full .NET drag/drop implimented smiling smiley

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: shashi jha (---.beesys.com)
Date: Tuesday, 01-Mar-2005, 15:05:07

hi,

i have used ur code for drag drop.all events are fired properly,
but item is not dropped.witch type items , we can drop.


public virtual DragLoadInfo CanConvertToHtml (DataObject dataObject)
{

//Check that the draged data is of desired format and return DragLoadInfo.CanConvert
foreach (string format in dataObject.GetFormats())
{
if(format == typeof(//DesiredType Like ToolboxItem).ToString())
{
return DragLoadInfo.CanConvert;
}
}
return DragLoadInfo.Unhandled;
}

i could not understand above method.what should i have to fill up in
comment section.

typeof(//DesiredType Like ToolboxItem).ToString())


suppose i am going to drop listview item , what should i do.
what is the use of

CanConvertToHtml
ConvertToHtml
methods.




waiting for ur reply

shashi

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: Alice.mm (222.90.17.---)
Date: Thursday, 01-Sep-2005, 11:46:45

hi,
Any one can post a simple solution to me ,thanks,my email is
cecilia_in_love@163.com ;I'm a c# learner,Thanks every one!!

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: Alice.mm (222.90.17.---)
Date: Thursday, 01-Sep-2005, 11:58:46

hi,
C an Any one post a simple solution to me?
thanks,my email is
cecilia_in_love@163.com ;
I'm a new c# learner,Thanks every one!! smiling smiley

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: Alice.MM (222.90.66.---)
Date: Wednesday, 07-Sep-2005, 01:49:56

If I add WebBrowser control in VB6.0 ,then I could drag items to it and drop,I think Com control to Com control is works ok ,but when add WebBrowser control in .net programe,it doesn't work.
You are right "WebBrowser control does not show HTML",but WebBrowser control has a DOM property,and use mshtml.HTMLDocument Interface ,I can control it's html,what I want to do is draging item into WebBrowser control,and when droped I add some html string into some where by mshtml.HTMLDocument interface.
If some one want simple code,I can send it to your Email adress,my email is cecilia_in_love@163.com .I really want help!
Also sorry for my poor English ,I'm not a English speaking country.smiling smiley

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: moon (211.176.234.---)
Date: Wednesday, 12-Oct-2005, 16:47:56

how i can ussed darg&drop

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: George Soules (---.greenmountainaccess.net)
Date: Sunday, 30-Oct-2005, 15:15:47

Attached is my version of drag and drop support. It is a simplified version of the code originally posted by Tomcat on 11-30-04 and 12-03-04. I can't guarantee that it's correct, but it seems to work for my application.

I am using Tim's original files with some minor modifications. The changes I made for drag and drop are detailed below. You need to edit HtmlEditor.cs, comsupport.cs, and HtmlSite.cs. Most of the code is new (marked "New"), but some existing code was modified (marked "Modified).

Note that my app subclasses HtmlEditor. The subclass overrides DropAllowed and OnDrop. My application-specified logic examines dataObject and takes appropriate action in these methods. This is similar to Tomcat's DataObjectConverter logic. I found, however, that the COM code could be much simpler if I let the subclass decide if draging/dropping was acceptable.

I hope this helps those of you that are looking for a simple example. I think this is about as simple as it can be and still work. Thank you to everyone who contributed to this thread and made it possible for me to add drag and drop to my app.

George


---- HtmlEditor.cs -----------------

// New
public virtual bool DropAllowed(DataObject dataObject, Point screenPoint)
{
return false;
}

public virtual void OnDrop(DataObject dataObject, Point screenPoint)
{
}


---- comsupport.cs --------------

// Modified
int GetDropTarget([In, MarshalAs(UnmanagedType.Interface)] IOleDropTarget pDropTarget,
[Out, MarshalAs(UnmanagedType.Interface)] out IOleDropTarget ppDropTarget);

// New
[System.Runtime.InteropServices.ComImport()]
[System.Runtime.InteropServices.InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
[System.Runtime.InteropServices.GuidAttribute("00000122-0000-0000-C000-000000000046")]
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public interface IOleDropTarget
{
[System.Runtime.InteropServices.PreserveSig()] int OleDragEnter (IntPtr pDataObj, [System.Runtime.InteropServices.MarshalAs(UnmanagedType.U4)] int grfKeyState, [System.Runtime.InteropServices.MarshalAs(UnmanagedType.Struct)] tagPOINT pt, ref int pdwEffect);
[System.Runtime.InteropServices.PreserveSig()] int OleDragOver (int grfKeyState, [System.Runtime.InteropServices.MarshalAs(UnmanagedType.Struct)] tagPOINT pt, ref int pdwEffect);
[System.Runtime.InteropServices.PreserveSig()] int OleDragLeave ();
[System.Runtime.InteropServices.PreserveSig()] int OleDrop (IntPtr pDataObj, [System.Runtime.InteropServices.MarshalAs(UnmanagedType.U4)] int grfKeyState, [System.Runtime.InteropServices.MarshalAs(UnmanagedType.Struct)] tagPOINT pt, ref int pdwEffect);
}


---- HtmlSite.cs ---------------

// Modified
public int GetDropTarget(IOleDropTarget pDropTarget, out IOleDropTarget ppDropTarget)
{
ppDropTarget = new DropTarget((HtmlEditor)container, pDropTarget);
return HRESULT.S_OK;
}

// New
private sealed class DropTarget : IOleDropTarget
{
const int DROPEFFECT_NONE = 0;
const int DROPEFFECT_COPY = 1;
const string guidForIDataObject = "0000010E-0000-0000-C000-000000000046";

private DataObject dataObject;
private IntPtr dataObjectPtr;
private HtmlEditor htmlEditor;

public DropTarget (HtmlEditor htmlEditor, IOleDropTarget originalDropTarget)
{
this.htmlEditor = htmlEditor;
}

public int OleDragEnter(IntPtr pDataObj, int grfKeyState, tagPOINT pt, ref int pdwEffect)
{
dataObject = new DataObject(Marshal.GetObjectForIUnknown(pDataObj));
IntPtr intPtr = Marshal.GetIUnknownForObject(dataObject);
Guid guid = new Guid(guidForIDataObject);
Marshal.QueryInterface (intPtr, ref guid, out dataObjectPtr);
Marshal.Release(intPtr);
pdwEffect = DROPEFFECT_NONE;
return HRESULT.S_OK;
}

public int OleDragOver(int grfKeyState, tagPOINT pt, ref int pdwEffect)
{
bool dropAllowed = htmlEditor.DropAllowed(dataObject, new Point(pt.x, pt.y));
pdwEffect = dropAllowed ? DROPEFFECT_COPY : DROPEFFECT_NONE;
return HRESULT.S_OK;
}

public int OleDrop(IntPtr pDataObj, int grfKeyState, tagPOINT pt, ref int pdwEffect)
{
DataObject draggedDataObject = new DataObject(Marshal.GetObjectForIUnknown(pDataObj));
htmlEditor.OnDrop(draggedDataObject, new Point(pt.x, pt.y));

IntPtr pUnk = Marshal.GetIUnknownForObject(dataObject);
Guid guid = new Guid(guidForIDataObject);
Marshal.QueryInterface(pUnk, ref guid, out dataObjectPtr);
Marshal.Release(dataObjectPtr);

dataObject = null;
dataObjectPtr = IntPtr.Zero;

return HRESULT.S_OK;
}

public int OleDragLeave()
{
if (dataObject != null)
{
dataObject = null;
Marshal.Release(dataObjectPtr);
dataObjectPtr = IntPtr.Zero;
}
return HRESULT.S_OK;
}

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: fadi (202.163.65.---)
Date: Thursday, 15-Dec-2005, 08:22:49

hi George Soules
i am using ur code , to do drag and drop on web browser control
but got stucked???
i am draging treenode and droping it on web browser control
can u tel me wat type of changes i should made in ur code to achive
this
waiting 4 ur reply

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: Ashish Sharma (---.siemens.com)
Date: Thursday, 05-Jan-2006, 02:43:15

Hi, I am getting GetDropTarget() called only the 1st time. For subsequent drag-drops, I don't get GetDropTarget() called.
Can someone suggest why this might be happening.

thanks,
ashish

Re: how to manipulate the darg and drop of the webbrowser editor!!
Posted by: Alice.MM (202.101.47.---)
Date: Tuesday, 28-Mar-2006, 00:47:05

public HTMLTextContainerEvents2_Event iEvent;
..........................................................
iEvent = (HTMLTextContainerEvents2_Event)(HTMLBody)(((HTMLDocument)(editocx.DOM)).body);
..........................................................

ed.iEvent.ondrop+=new HTMLTextContainerEvents2_ondropEventHandler(ed.iEvent_ondrop);
ed.iEvent.ondragover+=new HTMLTextContainerEvents2_ondragoverEventHandler(ed.iEvent_ondragover);
ed.iEvent.ondragenter+=new HTMLTextContainerEvents2_ondragenterEventHandler(ed.iEvent_ondragenter);
ed.iEvent.ondragleave+=new HTMLTextContainerEvents2_ondragleaveEventHandler(ed.iEvent_ondragleave);

...................................................................................
public bool iEvent_ondrop(IHTMLEventObj pEvtObj)
{
............
}
public bool iEvent_ondragover(IHTMLEventObj pEvtObj)
{
............
}
public bool iEvent_ondragenter(IHTMLEventObj pEvtObj)
{
............
}
public bool iEvent_ondragleave(IHTMLEventObj pEvtObj)
{
............
}

Go to Page: Previous123Next
Current Page: 2 of 3


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.
VhKJx
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.