Problem dropping item on WebBrowser component - c#

I would like to drop some controls from a self-defined toolbox onto a WebBrowser component. Because this component doesn't support drag-drop I use a wrapper to catch DragEnter, DragOver, ... This method worked fine while the application was still configured to work in .NET framework 2.0.
For some reasons I had to upgrade to .Net framework 4.0. All drag and drop functionality with my wrapper is broken. No events are triggered whatsoever. Events like "navigated" are still working fine...
I allready searched for possible answer and tried a few things but I couldn't fix it. Does anybody has any clue? Currently I'm thinking about implementing the wrapper given at: Codeproject
Thanks for your time!
EDIT 1 (& 2):
I continued my search for answers and discovered the following stuff:
The DragEnter-event should be fired somewhere because the right icon appears on the browser. This icon only seems to appear when a DragDropEffect is set correctly. But I can't find the handler for the DragEnter-event (or other).
I tried to drop the wanted item onto an other screen part. This part of the screen doesn't contain a lot of components so it was pretty easy to implement the drop-action there. And it worked fine. I was able to get the object out of the eventArgs. But it's still not working on the webbrowser-component.
Maybe these clues can help you to sort out this problem.

The first way I actually got working is by adding some events and there handlers within javascript code. The events I've set are:
ondragenter
ondragover
ondragleave
ondrop (NOT ondragdrop !!!)
By handling these events within javascript and sending the event to C#-code I could handle these events as wanted.
To get to the control I'm dragging I implemented a little "clipboard". With this static class I'm able to hold the control I'm dragging and access it from the "onDragEnter"-code.

Related

How to make it so when you drag the form it turns transparent [duplicate]

I have a Form object with a title bar displayed.
I need a pure managed way(P/Invoke-free, both Mono and .NET compatible, preferrably a .NET 2.0 API) to detect when the FORM itself starts being dragged, changes location and when it is dropped(not any content).
I did this in the past in Mono but I don't remember how anymore and I don't know if my solution was MS.NET-compatible...
If anyone could provide an example, three event names for me to google more details or point me to a relevant StackOverflow question, I would greatly appreciate. So far, my search has returned no relevant results...
Are you talking actual drag-drop operation here, or when the user moves the form? If it is the movement itself, you might be able to use the ResizeBegin event, which is raised when the user starts to move the form. This together with LocationChanged and ResizeEnd should cover your needs. However, the ResizeBegin and ResizeEnd events are (of course) also raised when you start and end resizing the form, not only when you are moving it.

WPF element hosted in ElementHost not redrawing correctly

I'm writing a program to implement COM component in C#. This component provides a UI component too. In the interest of making it easy to implement future additions to the component, I decided to write the UI in Xaml using WPF and wrapping it in an ElementHost control to provide the handle back to to the COM consumer.
Here's where this gets interesting. The element is being hosted in a win32 tab control. The first time the tab is selected, it loads fine. Switching to another tab and coming back causes it to not draw the component correctly. If I move the mouse through it, it'll draw the TextBox elements, but it'll never redraw the whole UserComponent.
I've tried every possible solution I've seen suggested, from changing the height/width values of the component to putting the HwndTarget in SoftwareOnly rendering mode.
I'm not sure what to try at this point, so suggestions are welcome. I'd really like to do this without using Windows Forms as the future maintainers of this aren't the best programmers and it's a lot easier to tell them to write up a Xaml file with data bindings than manually lay out a form and set the values in the code-behind.
Haven't met such problem yet.
Try to force refresh or focus (methods) to the hosting wrapper or HwndSource when switching to the hosting tab.

WPF find control under mouse without modifying the application

I'm creating a log system ('outside' the application) that logs all the click on the application. I have setup a PreFilterMessage function wich detects a click from the mouse, but I can't find the control/element that was clicked.
I've tried with Mouse.DirectlyOverbut the element is always null.
I've tried also with VisualTreeHelper.HitTest but I don't have a Visualto make the search from.
I don't have access to the inside of the application: only to the Main method (with the Application.Run(new MainForm()); and my Application.AddMessageFilter(new Logger());).
Does anyone have an idea (or a walk around) on how to get the clicked control in the application (in .Net 3.5)?
I've been using an amazing little application called Snoop for some time now that I think does exactly what you're after, it's open source (C#) and may be of use to you if you can find out how it works. (All WPF developers should get this and no I don't work on Snoop lol)
http://snoopwpf.codeplex.com/

Finding the mouseevents wpf c#

My question is very general, I'm making a project and referenced two projects(graphsharp and wpfextensions). These are helping me to create graphs.
When I created my graph for example I can easily drag the vertexes or move the graph by clicking the empty space in screen etc..
But I do not know what is happening in background, for multitouch capabilities, I need to find what is going on when a mouse event raised.
Therefore my question is how to find these events and methods in a lot of source files ?
Thanks.
The question does really general and fuzzy but probably some tool like Snoop http://snoopwpf.codeplex.com/ will help you (here you can take a look how it works and looks http://blois.us/Snoop/). There is "Events" tab for selected part of UI of your application where you can investigate all the way of Event through a visual tree and see who (which control) has handled this event. Then you should check the control that handled this event and see if it's something you are looking for.

Drag and Drop control for Silverlight

Recently I needed to add drag & drop functionality to a Silverlight application. Can anyone recommend a good drag & drop control?
I created a Drag/Drop controller that I think works really well. I have been using this technique for a while, and I have been very happy with it.
http://houseofbilz.com/archive/2009/02/10/drag-and-drop-with-silverlight.aspx
Here is a link to the best one I have found so far: http://nickssoftwareblog.com/2008/10/07/silverlight-20-in-examples-part-drag-and-drop-inside-out/
The code is available as a download from the blog post, although you have to rename it to a .zip: http://nickssoftwareblog.files.wordpress.com/2008/10/genericdragdropzip.doc
You can try Blacklight Controls which have a really neat drag-dock panel control. Here's a link to a blog describing how it works.
I recommend the Silverlight Toolkit for dragging and dropping elements within the same application.
It already has been updated for Silverlight 5.
I am guessing you have already found a solution by now. But here is a solution I wrote and am currently using which is very flexible and easy to use: http://sl4dragdrop.codeplex.com/
It works on SL5 very well, all you have to do is add dependency properties on the items or itemscontrol on which you want to enable dragging or dropping.
By default, that is enough. But if you want to customize parts of drag/drop, it gives you interfaces to implement that can control things like Element to drag, Which element to drag from, What image to show while dragging etc.
I have recently refined it a bit and will be posting an update soon after some more testing.

Categories

Resources