Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinForm : How to exclusively dock on a side of a screen

Tags:

c#

winforms

After hours searching, I still haven't found any solution to my need.

By saying Exclusively docking I mean that it takes a part of screen (Left, Right, Top or Bottom) and the rest other programs cannot use that part. If you have Windows 8, it looks like the small part of 2 divisions function in Win8.

I have the solution for WPF, but now I need to do it basing on WinForm.

Thanks in advance.

like image 254
Franva Avatar asked Jan 02 '13 04:01

Franva


People also ask

What is dock control?

Your dock control strategy should involve avoiding causes of dock proliferation (gaps in crops, weakened crops, spreading of dock seeds), assessing the dock density, and then selecting appropriate control measures.

What is anchor property in c#?

Remarks. Use the Anchor property to define how a control is automatically resized as its parent control is resized. Anchoring a control to its parent control ensures that the anchored edges remain in the same position relative to the edges of the parent control when the parent control is resized.

What is meaning of docking of controls in winforms?

Control.Dock. Controls that are docked fill the edges of the control's container, either the form or a container control. For example, Windows Explorer docks its TreeView control to the left side of the window and its ListView control to the right side of the window.


2 Answers

You could use this awesome solution over at code project (the author Corneliu is/was a MVP): http://www.codeproject.com/Articles/6045/Sticky-Windows-How-to-make-your-top-level-forms-to

Otherwise there is a great implementation from Hans Passant here: How to make my Windows Form app snap to screen edges?

Edit:

If you want to restrict other programs from using the space then try Arik Poznanski's c# Application Desktop Toolbars method: http://www.codeproject.com/Articles/3728/C-does-Shell-Part-3

like image 102
Jeremy Thompson Avatar answered Oct 24 '22 22:10

Jeremy Thompson


I can check tomorrow, but I believe when I implemented this, I used this as a guide.

http://www.codeproject.com/Articles/6741/AppBar-using-C

like image 28
recursive Avatar answered Oct 24 '22 21:10

recursive