0

When I use this code to hide the windows border:

this.FormBorderStyle = FormBorderStyle.None;

I loose control of moving it around is there a way to add some code that will allow you to click and drag anywhere within the form itself?

G Gr
  • 6,030
  • 20
  • 91
  • 184
  • 4
    you can't move a window by clicking/dragging on its client area unless you write some code for mouse events. Try to move your browser by clicking to this text. – L.B Mar 07 '12 at 22:04
  • HAA good point not sure why I overlooked that, I guess its just instinct to click the borders of forms. I noticed most of my game apps have (click drag) anywhere on the form, I will update my question now. – G Gr Mar 07 '12 at 22:08

2 Answers2

1

Short answer, no. There is no such thing built-in to WinForms. You will have to add an event handler on the client area and handle the window move yourself. To avoid duplicating answers, I send you back to this post

Community
  • 1
  • 1
GETah
  • 20,922
  • 7
  • 61
  • 103
  • GETah is there any instructions available on how to do this, have you came across it on your travels got a link maybe? – G Gr Mar 07 '12 at 22:12
  • This is incorrect. The Win32 API supports this, and therefore WinForms does as well. [See my answer here](http://stackoverflow.com/questions/9321899/creating-non-rectangular-forms-that-can-be-moved-by-dragging-anywhere-in-the-bac/9322021#9322021) for instructions. I do not recommend doing it yourself by handling mouse events. – Cody Gray - on strike Mar 07 '12 at 23:03
  • @CodyGray And so does anything running native on Windows. The question is about WinForms, not low level Win32 API. Win32 API is not part of any WinForm package and requires external native calls so is not WinForms. Think of this program runnin on Mono? How would you acheive this using Win32 API on a Linux based system? – GETah Mar 07 '12 at 23:07
  • @GET: That's what WinForms is: a wrapper around Win32. – Cody Gray - on strike Mar 07 '12 at 23:11
  • @CodyGray Just went through the documentation again, what you said is correct. Many things can be achieved by overriding `WndProc` – GETah Mar 12 '12 at 17:27
0

Instead is relatively easy to do with Windows API.
We need to persuade the window manager into believing that we clicked on the caption of the window.
Look at the sample in this project

Steve
  • 213,761
  • 22
  • 232
  • 286