CreamInstaller/CreamInstaller/Components/CustomForm.cs
2022-03-03 08:56:44 -05:00

27 lines
808 B
C#

using System.Windows.Forms;
namespace CreamInstaller.Components;
internal class CustomForm : Form
{
internal CustomForm() : base() => Icon = Properties.Resources.Icon;
internal CustomForm(IWin32Window owner) : this() => Owner = owner as Form;
protected override CreateParams CreateParams // Double buffering for all controls
{
get
{
CreateParams handleParam = base.CreateParams;
handleParam.ExStyle |= 0x02000000; // WS_EX_COMPOSITED
return handleParam;
}
}
internal void InheritLocation(Form fromForm)
{
int X = fromForm.Location.X + fromForm.Size.Width / 2 - Size.Width / 2;
int Y = fromForm.Location.Y + fromForm.Size.Height / 2 - Size.Height / 2;
Location = new(X, Y);
}
}