I am creating a fullscreen demo application (demo = not production, so hacky code is okay though not preferred) for the Kinect SDK. The application hides the Windows cursor and shows a custom hand cursor which is defined as a object.
What I would like to do is create a custom UserControl (let's call it "HoverControl") that can detect when the cursor object is over it and then send back timer ticks, allowing the cursor object to update in some way (showing the user that something is about to happen).
The behavior is pretty much a copy of the Xbox 360 Kinect behavior. How things look will just be a little different.
How can I detect with the cursor object is over a "HoverControl" and have receive a callback from the HoverControl?
Thank you for any help or suggestions!
CLARIFICATION:
I am not currently moving the Windows cursor, so MouseEnter doesn't fire.
You can use your own cursor by making one using Online Cursor Maker. See this website on how to set it. Then you can use MouseEnter and/or MouseLeave.
Coding my own cursor in XAML, and creating a UserControl out of it, I set up a timer inside the control to perform a hit test for certain buttons (again, their own unique UserControl type) around my interface.
I ran into one issue with the hit test, which I was ultimately able to solve and detail in the following post at MSDN:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/a8cdb265-21cc-4fd0-b40d-e6778b659852
Related
(Crosspost to Mixed Developer forums because they're still very inactive.)
Going through the HoloToolkit examples, I'm trying to reproduce the button input example in the InputManagerTest example for a GUI I'm making. Reproducing the button seems to cause a hiccup though. Here's what I do:
I add a Canvas
I add a Button to that Canvas
That's basically it. This looks very similar to the example. My scene, as well, as the InputManager, EventSystem, and Camera as instructed in the tutorial.
However, in the example, the button responds to Gaze, and hand click, which is what I want.
In my example, my button responds to my mouse and mouse click though. I also cannot change its color from the default.
Does anyone know why this all would be?
I can answer my own question. Standalone Input Module is automatically added as a component of the Event System in the current build. This sets the default input to be the mouse cursor. Disabling this component fixes the issue.
I've set my XNA game's DeviceWindowHandle to a PictureBox with Dock set to Fill on a Form, effectively providing the powerful array of .NET controls to my game. I'm aware this comes with a handful of niggly things to clean up, one of which is my problem explained below.
I'm trying to figure out if it's possible to avoid the WM pump pausing when doing things like clicking to drag a ScrollBar control, or right clicking in a TextBox control, this ultimately causes my renderSurface (the dock filled pictureBox) to stop being drawn to temporarily. Information on this seems sparse, though it's likely i'm not looking in the right places.
I could tie in some custom drawn XNA ScrollBars and set ShortcutsEnabled on the .NET TextBox's to false, but i would rather fix the root of this problem if possible.
Thanks in advance.
XNA works by having a game loop. WinForms and native c++ Windows GUI apps work by having a message pump. Sounds like you have fused the two somehow.
Perhaps you need to call the base Game.Update() somehow from within your forms's Control.WndProc
I've tried searching for the answer to this issue but I've been unlucky trying to find it.
From similar questions on here I've been able to make my transparent window receive mouse events, but then the other applications running behind it don't get any mouse events (Set the background of the window to #01000000 (mostly transparent)).
Or the alternative I've also achieved: the transparent window gets no mouse events and they are all passed through.
Is there a way to combine these 2 and have a transparent window that both interprets mouse events and passes them to whatever is behind it? My end goal would be to display a *ping* graphic on the transparent window (which is the same width/height of my desktop resolution) any time the mouse is clicked on the screen while I'm using other applications.
Further edit:
I have a Canvas in my WPF window. It has MouseLeftButtonDown as an element which calls a method in the behind-code. This method does not seem to get called when I use the solution that I linked, or when I simply set the Window and Canvas to Transparent or #00000000.
I think a better approach would be to use windows hook to catch global mouse events, and simply let your application discard mouse hit tests. As far as I know, Windows hook are not directly available in the .NET framework, but they are PInvokable.
Microsoft provides a pretty straightforward guide for this here.
I implemented something in Windows Forms similar to DragMove but with boundaries set to 10 units of the margins of the primary screen.
When switching over to WPF I found this thread to be useful in achieving the same result.
However, since this is a post-move event, what happens is that if my window is dragged beyond the boundaries I set, it "jumps" back. I would like to avoid this effect as it looks terrible.
Is there a simple way to avoid the window to be moved outside a given area without using the LocationChanged event? I basically want to restrict the movement of the window before it happens.
These this are very hard to achieve with WPF because it does not expose the base Win32 functions and events like WinForms did. I had a project where I needed to to resize a window and I had to use PInvoke SetWindowPos to do this in a normal manner.
AddHook may help you, but this will still be quite difficult. See http://www.wpfmentor.com/2009/01/how-to-get-hwnd-and-hook-into-wndproc.html and http://msdn.microsoft.com/en-us/library/system.windows.interop.hwndsource.addhook.aspx for more information.
I've a winforms app that "docks" to the taskbar
I'd like to autohide the form and make it appear only when the mouse goes near/over the form
any suggestions ?
Install a global hook onto the mouse-move event and check to see if it is within the form boundaries. Should work even with the form hidden. If not just store the location as a rectangle and check against that.
Code for a simple and handy global hook implementation can be found at:
http://www.codeproject.com/KB/cs/globalhook.aspx
I've used this method to create "hotspot" functionality to a user desktop.
I'm not sure it is exactly answering your question, but there is a sample of this on Codeplex...
http://remoteaccessmonitor.codeplex.com/
Browse the source code and check out the MinimizeToTray.cs file - it has examples of pop up messages when hiding and I think its default behaviour is to re-appear on click (although I imagine this could be changed).
You could.
Poll mouse coords until it's within a certain radius of your app.
Position an invisible, always-on-top form above the docked app and have it fire a MouseEnter event.
That's all I can think of really. Either.