views:

112

answers:

4

Hello everyone,

I just would like to know if it is possible to dock a windows form on top of the user screen? I have been trying to do this by manually setting the position of my form to the coordinates I want. But using this method, however, allows the user to change the position of the form just by dragging it. I want to make the form docked to the upper portion of the screen since this window form will server as a menu for the project i am making.

Thanks a lot. :)

+1  A: 

You might find the answer to your question here. Google is your friend. Look towards to bottom of the page.

Eric
i've seen this page. i've tried using the DesktopLocation property and I can't make it work the way i wanted it to. It docks the form (yes it does) but it docks it in the screen's upper lefthand corner. I want it, however, to be docked on the upper center screen.
Kim Rivera
A: 
Will Marcouiller
hello, thanks for the response. I'm a bit new to using the extensive functionalities of Visual Studio 2008 and i quite don't know how I can use the Control.Dock property. Can you please give me some examples on how I can use those properties? thanks :)
Kim Rivera
That's for docking controls within a form, not for docking the entire form.
Jouke van der Maas
@Jouke Van Der Maas: I guess you didn't read all of my answer. I mention the `DesktopLocation` property, that is, for docking the whole window on the desktop. Furthermore, I suggest that this might be a better tool for the job after the OP precised his idea. Please revise your comment accordingly.
Will Marcouiller
@Will Marcouiller You must've edited, i will now remove my downvote. Nevermind I can't unless you edit again.
Jouke van der Maas
@Jouke Van Der Maas: I edited my answer for you to remove your downvote, if you wish so. However, please see your comment age in comparison to my edit age. I had edited 4 hours before you let your comment. Never mind anyway, the most important is that we now both agree that my question might help.
Will Marcouiller
this helped me with a new idea of how to do my project. thanks a lot :)
Kim Rivera
You're welcome friend! =)
Will Marcouiller
A: 

Hello everyone,

So after some tweaks I finally was able to get this code working.

this.DesktopLocation = new Point((Screen.PrimaryScreen.Bounds.Width / 2 - 420), 0);

I placed that line below the InitializeComponent() and it docks my form to the center of the screen with whatever resolution values. However, what I now need is to make this form like a bound wherein all the other forms that would open will not go at the back of this. if you try opening a form with this code and opening another maximized form the maximized form will go at the back of this form. meaning they overlap which I don't want to happen.

If anyone knows how to do this, please inform me. thanks :)

Kim Rivera
A: 

By setting the FormBorderStyle of your form to None, you take the drag handle away from the user so they cannot move it via the mouse.

Then you just need to place it where you want.

If you really want to take away the users options you can also set the ShowInTaskbar property to false

Seattle Leonard