Create a dock like application using C# and wpf

南楼画角 提交于 2019-12-10 21:24:40

问题


I need to create a application which is similar to those we will get when we buy a laptop. It will be visible only when the mouse pointer reaches the top of the window. So how can I able to do this using C# 4.0 ? http://www.notebookcheck.net/uploads/pics/win2_12.jpg this link u can see the application. I need to create such type Any idea pls share. Thanks


回答1:


I suppose there are several different ways to achieve this effect:

  • You can place part of the window of your application above the visible screen, so only a part of it is visible (let's say you can see only it's bottom). Then you need to handle events when mouse enters (MouseEnter) and leaves (MouseLeave) the form to move the form up and down.
  • You can use a background thread to call GetCursorPos method at a set interval (i.e. each 500ms) second to check where currently the mouse is. See this link for more information about it and a sample code: http://www.pinvoke.net/default.aspx/user32.getcursorpos. (If you need only to check the mouse position, you can use a timer to simplify you application.)



回答2:


When you hit what's possible with C#, you can always start invoking native code - such as the windows API. Since you don't ask a specific question, I'll leave you with:

  • Position your app where you want it to appear and hide it.
  • Capture mouse position with windows api (see this SO answer)
  • When mouse is at screen corner / top, etc; make your app visible.

Now make sure all this works with dual screen setup, and you are done.



来源:https://stackoverflow.com/questions/9849853/create-a-dock-like-application-using-c-sharp-and-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!