Grhm
Grhm

Reputation: 6834

Stop Dragging from a WPF WebBrowser control

I have a WPF application which contains a WebBrowser control.

Currently, the user can select something within the WebBrowser and can copy the content by dragging it out to another application and dropping it there.

I'd like to be able to stop the user doing this. I'd assumed that there would be a "DragStart" event that I could capture and cancel - but I haven't been able to find something so simple.

Is it possible to capture the start of drag event and cancel it?
Is there a better way to achieve this?

Upvotes: 0

Views: 1603

Answers (1)

Sheng Jiang 蒋晟
Sheng Jiang 蒋晟

Reputation: 15261

You can implement IDocHostUIHandler::FilterDataObject and filter out common clipboard formats

You don't get access the WPF browser's native interface until the document is ready. Not sure if it would work with the WPF browser class. There is also a bug in Windows Forms to prevent you from customizing its implementation of IDocHostUIHandler.

You can try some wrapper class of the webbrowser ActiveX, such as the one described at http://www.codeproject.com/KB/miscctrl/csEXWB.aspx

Upvotes: 1

Related Questions