C# Autohide form
I've a winforms app that "docks" to the taskbar I'd l开发者_运维技巧ike 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.
精彩评论