473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Custom IDropTarget problem by hosting mshtml

Hi there

In my app I host the webbrowser. If I return my own implementation in
GetDropTarget my methods are never called ( if i return the original
dropTarget or NOTIMPLEMENTED everything works fine)

Framework 1.1

please help

ps to contact me replace -aT-
d.mohl-aT-hico.com

Nov 16 '05 #1
2 3356
dom,

Have you implemented IDocHostUIHandler? You will get control there for
GetDropTarget.

Paste the code so that i can investigate, if it doesnt work.
Shak.
<do*@doesntexist.com> wrote in message
news:ca**********@newsreader1.utanet.at...
Hi there

In my app I host the webbrowser. If I return my own implementation in
GetDropTarget my methods are never called ( if i return the original
dropTarget or NOTIMPLEMENTED everything works fine)

Framework 1.1

please help

ps to contact me replace -aT-
d.mohl-aT-hico.com

Nov 16 '05 #2
dom
Yes, I implemented the IDocHostUIHandler

Here the relevant codeparts

the GetDropTarget will be called but DropTarget.OleDragEnter is never called
public int GetDropTarget(Interop.IOleDropTarget pDropTarget, out
Interop.IOleDropTarget ppDropTarget)

{

if (_dropTarget == null)

{

HtmlEditor editor = (_hostControl as HtmlEditor);

if (editor != null)

{

DataObjectConverter converter = editor.DataObjectConverter;

if (converter != null)

{

_dropTarget = new DropTarget(editor, converter, pDropTarget);

}

}

}

ppDropTarget = _dropTarget as Interop.IOleDropTarget;

if (ppDropTarget != null)

{

return Interop.S_OK;

}

return Interop.E_NOTIMPL;

}

protected sealed class DropTarget : Interop.IOleDropTarget

{

private HtmlControl _owner;

private DataObject _currentDataObj;

private IntPtr _currentDataObjPtr;

private Interop.IOleDropTarget _originalDropTarget;

private DataObjectConverter _converter;

private DataObjectConverterInfo _converterInfo;

public DropTarget(HtmlControl owner, DataObjectConverter converter,
Interop.IOleDropTarget originalDropTarget)

{

_owner = owner;

_converter = converter;

_originalDropTarget = originalDropTarget;

}

#region Drag and Drop

public int OleDragEnter(IntPtr pDataObj, int grfKeyState, long pt, out int
pdwEffect)

{

pdwEffect = Interop.DROPEFFECT_NONE;

DataObject dataObject = new
DataObject(Marshal.GetObjectForIUnknown(pDataObj)) ;

_converterInfo = _converter.CanConvertToHtml(dataObject);

if (_converterInfo == DataObjectConverterInfo.CanConvert)

{

_currentDataObj = new DataObject(DataFormats.Html, String.Empty);

IntPtr i = Marshal.GetIUnknownForObject(_currentDataObj);

Guid guid = new Guid("0000010E-0000-0000-C000-000000000046");

Marshal.QueryInterface(i, ref guid, out _currentDataObjPtr);

Marshal.Release(i);

return _originalDropTarget.OleDragEnter(_currentDataObjPt r, grfKeyState, pt,
out pdwEffect);

}

if (_converterInfo == DataObjectConverterInfo.Disabled)

{

pdwEffect = Interop.DROPEFFECT_NONE;

}

else if (_converterInfo == DataObjectConverterInfo.Unhandled)

{

return _originalDropTarget.OleDragEnter(pDataObj, grfKeyState, pt, out
pdwEffect);

}

return 0;

}

public int OleDragOver(int grfKeyState, long pt, out int pdwEffect)

{

if (_converterInfo != DataObjectConverterInfo.Disabled)

{

return _originalDropTarget.OleDragOver(grfKeyState, pt, out pdwEffect);

}

pdwEffect = Interop.DROPEFFECT_NONE;;

return 0;

}

public int OleDragLeave()

{

_converterInfo = DataObjectConverterInfo.Disabled;

if (_currentDataObj == null)

{

return 0;

}

_currentDataObj = null;

Marshal.Release(_currentDataObjPtr);

_currentDataObjPtr = IntPtr.Zero;

return _originalDropTarget.OleDragLeave();

}

public int OleDrop(IntPtr pDataObj, int grfKeyState, long pt, out int
pdwEffect)

{

Form form;

pdwEffect = Interop.DROPEFFECT_NONE;

int i = 0;

Control control = _owner;

if (control != null)

{

control = control.Parent;

form = control as Form;

if (form == null)

{

return 0;

}

form.BringToFront();

return 0;

}

if (_converterInfo == DataObjectConverterInfo.CanConvert)

{

DataObject dataObject = new
DataObject(Marshal.GetObjectForIUnknown(pDataObj)) ;

if (_converter.ConvertToHtml(dataObject, _currentDataObj))

{

IntPtr j = Marshal.GetIUnknownForObject(_currentDataObj);

Guid guid = new Guid("0000010E-0000-0000-C000-000000000046");

Marshal.QueryInterface(j, ref guid, out _currentDataObjPtr);

i = _originalDropTarget.OleDrop(_currentDataObjPtr, grfKeyState, pt, out
pdwEffect);

Marshal.Release(_currentDataObjPtr);

_currentDataObj = null;

_currentDataObjPtr = IntPtr.Zero;

}

else

{

pdwEffect = Interop.DROPEFFECT_NONE;

}

}

else if (_converterInfo == DataObjectConverterInfo.Unhandled)

{

i = _originalDropTarget.OleDrop(pDataObj, grfKeyState, pt, out pdwEffect);

}

_converterInfo = DataObjectConverterInfo.Disabled;

return i;

}

}
"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:uy**************@tk2msftngp13.phx.gbl...
dom,

Have you implemented IDocHostUIHandler? You will get control there for
GetDropTarget.

Paste the code so that i can investigate, if it doesnt work.
Shak.
<do*@doesntexist.com> wrote in message
news:ca**********@newsreader1.utanet.at...
Hi there

In my app I host the webbrowser. If I return my own implementation in
GetDropTarget my methods are never called ( if i return the original
dropTarget or NOTIMPLEMENTED everything works fine)

Framework 1.1

please help

ps to contact me replace -aT-
d.mohl-aT-hico.com


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ven | last post by:
Hi all I would like to implement this interface for my C# Class,The IDropTarget interface calss..has been created I am having problem with the compilation of the RegisterDragDrop(...
1
by: Dean Hallman | last post by:
I need to ensure client machine has Microsoft.mshtml installed in the GAC. And if not, deploy it. My app is a Browser Helper Object and depends on mshtml. Initially, I thought I could take care...
4
by: David Pendrey | last post by:
Hello all, I am using the WebBrowser control to browse a webpage containing frames and am having difficulties accessing the 'frames' property of a document object. Bellow is my code and the error...
10
by: Hans Merkl | last post by:
Hi, I have written an pap with .NET 2.0 and c# that uses MSHTML. It works fine on my development machine but on machines I deploy it to I get the following exception when ever I call MSHTML. ...
2
by: DotNetShadow | last post by:
Hi Guys, I have been reading heaps of information in regards to MSHTML object being used in .NET applications, windows and UI-less. I have read the walkall samples and tried various techniques...
5
by: Graham | last post by:
I have created a custom MembershipProvider called "LassieMembershipProvider" that derives from "MembershipProvider". This providor is located in a Businesslogic layer dll called...
5
by: Atara | last post by:
I am trying to convert the following code to VB .Net, I still have some gaps (the lines that are marked with (*)) and also I need an ending condition for the while loop. any help would be...
0
by: Atara | last post by:
Our application was build with VS 2003. I have tried to run it on a computer with .Net 2.0 (but without .Net 1.1 , as it should be used) and I got the following error - ...
5
by: Jason | last post by:
Hi, I'm developing an HTML Editor Control using VB.Net 2003 for an application that used to use the DHTML Editor Control that is no longer supported. Well, it's been fun but I've hit a wall with...
0
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.