Hello,
does anyone have code example how to move Borderless Form when Mouse1 is pressed? I want to have simple borderless window with 4 labes (Start, Readme, Homepage, Exit) on it and ability to move all form with mouse, that's all.
Any advice?
Borderless Form - how to move with Mouse1?
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- ALIENQuake
- Posts: 112
- Last visit: Mon Jan 29, 2024 7:35 am
- Has voted: 4 times
Re: Borderless Form - how to move with Mouse1?
It will require some C# code but it can be done:
https://www.codeproject.com/Articles/11 ... lebar-in-C
You will need to use Add-Type to generate the code for the necessary calls to the Windows API.
https://www.codeproject.com/Articles/11 ... lebar-in-C
You will need to use Add-Type to generate the code for the necessary calls to the Windows API.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Borderless Form - how to move with Mouse1?
Here is some old code that does the moving. You can add it as a "snippet" and insert whenever needed.
Code: Select all
Add-Type @'
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
public class User32{
//const and dll functions for moving form
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
}
'@
$form1_Load={
}
$form1_MouseDown=[System.Windows.Forms.MouseEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.MouseEventArgs]
[user32]::ReleaseCapture()
[user32]::SendMessage($form1.Handle, [user32]::WM_NCLBUTTONDOWN, [user32]::HT_CAPTION, 0);
}
- ALIENQuake
- Posts: 112
- Last visit: Mon Jan 29, 2024 7:35 am
- Has voted: 4 times