tags:

views:

321

answers:

2

I have a WinForms program written on .NET 2 which hosts a webbrowser control and renders asp.net pages from a known server.

I would like to be able to drag, say, a tree node from a treeview in my winforms app into a specific location in the hosted web page and have it trigger a javascript event there. Currently, I can implement the IDocHostUIHandler interface and getting drag\drop events on the browser control, then call Navigate("javascript:fire_event(...)") on the control to execute a script on the page. However, I want this to work only when I drop data on a specific part of the page.

One solution, I suppose, would be to bite the bullet and write a custom browser plugin in the form of an activex control, embed that in the location I want to drop to and let that implement the needed drag\drop interfaces.

Would that work? Is there a cleaner approach? Can I take advantage of the fact that the browser control is hosted in my app and provide some further level of interaction?

+1  A: 

Take a look at the BrowserPlus project at Yahoo

http://browserplus.yahoo.com/

It looks like they have built a toolkit so that you don't have to do the gritty work of writing the browser plugin yourself.

Justin Walgran
A: 

If you can find out the on screen position of the part of the page you are interested in, you could compare this with the position of the mouse when you receive the drop event. I'm not sure how practical this is if you can get the info out of the DOM or whatnot.

As an alternative could you implement the mouse events on the bit of the page using javascript?

Ben Childs