I have a borderless form that I want to be movable. I have used @Joey's solution In order to do that. but after I did it I have noticed that my Click
event is no longer activated when my form Form1
is clicked. How can I have both the functionality of the mobile borderless form and the ability to activate the function form1_Click()
onclick?
Asked
Active
Viewed 45 times
0
-
If you say (with SendMessage) that the MouseDown (`WM_NCLBUTTONDOWN`) is on the Caption (`HT_CAPTION`), or in a `WM_NCHITTEST` (WndProc) you return `IntPtr(2)` = `HTCAPTION`, then the mouse events are no longer directed to your Form. You can use one of the other answers, using the MouseDown and MouseMove events. BTW, you don't need to PInvoke `ReleaseCapture()`, can set `this.Capture = false;`, same thing. – Jimi Oct 09 '19 at 18:27
-
@Jimi is jay_t55 answer's valid? – Oct 09 '19 at 18:35
-
Yes, it's one of the possible ways. I assume you want to move your Form clicking anywhere on it, so you don't have a *fake* title bar. – Jimi Oct 09 '19 at 18:37
-
@Jimi If I want a specific location in the form to be clicked in order to move it (and all the rest will not have that functionality), is that possible? I know it is not part of the question but just I tried to do it and it didn't work out – Oct 09 '19 at 18:40
-
Of course. You can use another control (a Label, for example) and handle the `MouseDown`, `MouseMove` events of this control. Or you can define an area, as a Rectangle, and determine whether the current mouse position is included in this area using the [Rectangle.Contains(Point)](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.rectangle.contains) method. – Jimi Oct 09 '19 at 21:48