How do I move a window that does not have a border. There is no empty space on the application, all that is available is a webbrowser and a menustrip. I would like the users to be able to move the window by dragging the menu strip. How do I code this? I have tried a few code blocks I have found online, but none of them worked.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
If you are using a Panel you have to add this in the
YourForm.Designer.cs
and this in the
YourForm.cs
Mbithi Kioko is on the right track but i would do it this way.
I had to use
System.Runtime.InteropServices.DllImportAttribute
- just thought I would comment and let you all know.This Code Project article should help you accomplish this. I've used this myself with no problems. This is the jist of it:
This will basically "trick" the window manager into thinking that it is grabbing the title bar of the winform.
To apply it to your project, just use the MouseDown event from the MenuStrip.
Here is the .Net Way
that's it.
You can fake your menustrip, for example using a panel with a label instead. And then you can handle this manually: when the user clicks the label, a popup menu will open, and when the user drags the label, the window will move. But I would advise against such workarounds, because it's not a standard GUI behavior, and you might get your users confused.