Click here to Skip to main content
15,942,710 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
please help me i want to make a clean windows form design with no border and lines on it also it have to be resizable and movable.
Sergey Alexandrovich Kryukov 26-May-15 17:02pm    
What have you tried so far?

1 solution

Borderless form is simple:[^],[^] (use System.Windows.Forms.FormBorderStyle.None).

Now, how to implement move and resize operations? Well, there is no such thing as miracle. By removing borders, you lost non-client form areas, so you have to emulate similar behavior on the client area of the window.

Here is what you can do:
You can handle mouse events on the form itself, but you could better add some controls representing title bar and borders to put this functionality on them. Also, alternatively, you can adjust the client area size by using Control.SetClientSizeCore, as explained in my recent answer:
how can I change the thickness of a form border[^].

No matter what control you use, for move or resize operation, you do the same things by handling the events MouseDown, MouseUp and MouseMove, or, better yet, by overriding the Control's virtual methods OnMouseDown, OnMouseUp and OnMouseMove:[^].

Have some flags, members of your window, such as modeMode, resizeMode or bitwise combinations in one byte. On "down" event, set move or resize mode. In case of resizing, you will also need to capture mouse to the form:[^].

Capturing mouse is important because your next step, move of the mouse, may move the mouse pointer outside of the form area, but you still need to handle "move" and "up" events in your form.

Then, on mouse "move" event, perform resize or move, and on "up" event stop capturing mouse and go back to "normal" mouse mode. It will require some logic, so be patient and thorough. One more detail: you may want to work in screen coordinates instead of control coordinates, or in form coordinates (which is another control), instead of tool control coordinates. This is how:[^],[^].

That's all.

Share this answer
Sascha Lefèvre 26-May-15 22:39pm    
Sergey Alexandrovich Kryukov 27-May-15 0:04am    
Thank you, Sascha.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900