Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drag and Drop to a hosted Browser control

Tags:

browser

c#

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?

like image 557
HS. Avatar asked Aug 07 '08 15:08

HS.


2 Answers

Take a look at the BrowserPlus project at Yahoo.

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.

like image 115
Justin Walgran Avatar answered Oct 05 '22 17:10

Justin Walgran


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?

like image 25
Ben Childs Avatar answered Oct 05 '22 17:10

Ben Childs