Wpf hosting windows form - mouse events not getting through - c#

I've got a WPF app that has a WindowsFormsHost, which hosts a geobase map.
The problem I have is getting the mouse events through to the map. I've added MouseUp event handlers to the map (in code), but this does not work, and I've tried adding the MouseUp event handler on the Grid that contains the WindowsFormsHost, but the events are not picked up by this either.
I'm not sure whether this is a general WPF problem with the way I'm handling events, or a more specific problem that is specific to hosting Windows Forms apps in WPF...
Any pointers would be appreciated :)

As far as I understand you need to call WindowsFormsHost.EnableWindowsFormsInterop() for events to be forwarded to your winforms code.

Related

Auto scroll on Drag And Drop: UWP

I am developing UWP application. In one scenario, I am having multiple ListView on a canvas and I want to perform Drag and Drop between ListViews. While performing Drag-Drop scroller doesn't moves.
I tried to implement Behaviour defined in this Link. But it is not working as PreviewDragOver event is not available in UWP.
Is there any way to implement it ?
While PreviewDragOver is not available in UWP, the DragOver event definitely is. It seems it should be possible to use this event in the attached behavior instead.

WPF - Making DragDrop and ManipulationEnabled co-exist

I have a somewhat unusual design problem in a WPF touch application.
I have a UserControl that holds an image, which I allow the user to freely move, resize, and rotate around the touch surface using multitouch by setting:
isManipulationEnabled = true
and then hooking up events for ManipulationStarting, ManipulationDelta, and ManipulationCompleted.
This is all good and works perfectly, but now I would like to add the ability for a user to drag this control into the WrapPanel on another control, which has a list of image files, and add this image to the list.
I tried using DragDrop events by calling DragDrop.DoDragDrop() on the ManipulationDelta event, but it locks the UI and the control until a drop occurs, which is not what I want.
Is there any way to properly do this without writing my own hit-testing code? I'm using WPF 4.0 and .NET 4.5 on VS 2013, and I'm not sure if the Surface SDK would help me in this case (nor could I properly install/load it to VS2013)
Found my solution: Use VisualTreeHelper.HitTest and call the HitTest in the event handler for ManipulationDelta, and then use your own logic for handling the drag over operation. Use ManipulationCompleted event to check the hit test again to complete the drop

C# Suppressing mouse click for multiple mice

I have written an application that currently handles clicks from multiple mouse devices.
I used this project and modified to handle mouse clicks as apposed to keyboards.
This is working fine, however now I need to know if there is a way to suppress a click event if it has been handled by my app. The app is a quiz game so the idea is that the quiz master will have (and still be able to use) 1 mouse, and the other contestants will have their own mouse (as buzzers). So when they buzz in, I don't want the mouse click events to fire in the operating system (or at least this application).
The concept is the familiar override of void WndProc(ref Message message), and so I have tried not calling base.WndProc(ref Message) when I don't want the click events to fire, but this has not worked.
Can anybody point me in the right direction here?
Should I be going down the windows hook route? I have looked at this, but I can't seem to work out how I could hook to each mouse device individually.
Any help would be greatly appreciated.
Edit:
This is a Windows Form UI project, and not WPF. So the MultiPoint SDK from Microsoft won't work.
The solution to this lies within not WndProc, but PreFilterMessage(). By intercepting messages before they even reach the form, you can remove them from the message pump causing them to never reach the control that was clicked. This also works for child controls within the form.
I answered this and posted the full source in the following question:
C# Get Mouse handle (GetRawInputDeviceInfo)

How do I implement touch event for my application?

I want to implement touch event in my Win-Form application. Touch events for buttons, list, combo box and check box. Any idea how do I implement it ? I couldn't find any resources for the same.
I just want my application to be completely compatible with the touch screen Tablets. I use .NET 3.5 and don't see any relevant event handlers. Am I missing any thing ?
I think you are missing something.
I think the "touch" event you are looking for is in fact a "single click" if running win forms on a tablet.
Handle the OnClick event.
You can do so by using Selecting event handler dor respective controls

Problem dropping item on WebBrowser component

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.

Categories

Resources