Question

I'm making a WPF application which can be docked to one of the edges of the desktop. I do this by having an 'EdgeWindow' which is a transparent 5px wide window on the same edge of the screen, whenever the mouse goes over that then the window of the application will popup.

The problem is that while the 'EdgeWindow' is set to 'Topmost' other Windows applications also set their window to 'Topmost' which means that the EdgeWindow can end up underneath some windows. There doesn't seem to be a guaranteed way to keep the EdgeWindow on top as far as I can tell.

My application is already an 'ApplicationDesktopToolbar (similar to http://www.codeproject.com/KB/shell/csdoesshell3.aspx) so I was hoping there might be some way using that infrastructure to determine whether the window should popup and get rid of the 'EdgeWindow' entirely but I couldn't see anything there that would help.

Was it helpful?

Solution 2

The solution I ended up using was to listen for any changes in the mouse position and pop up the window if it nears the edge. Of course, normal WPF mouse listening won't work when the cursor goes outside the application.

Original I planned to WH_MOUSE_LL but it seems like that functionality doesn't work well in Windows 7 since in Windows 7 they unregister any attached hooks every now and then for some reason.

Ultimately I ended up using 'RawInput' (http://www.codeproject.com/KB/system/rawinput.aspx) which works pretty well. The example only shows how to retrieve keyboard input events but it wasn't that difficult to change it to listen for mouse move events instead.

OTHER TIPS

I tried to do a similar project a while using the ShAppBar class; if you are using the ShAppBar class, which you say you are, there shouldn't be a need to have an invisible topmost window. Also the link to the code you provided seems to contain the following:

GetAutoHideBar            = 0x00000007,    
// Registers or unregisters an autohide appbar for an edge of 

// the screen. 

SetAutoHideBar            = 0x00000008,    
// Notifies the system when an appbar's position has changed. 

WindowPosChanged          = 0x00000009,    
// Sets the state of the appbar's autohide and always-on-top 

// attributes.

SetState                  = 0x0000000a        

Does this not work?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top