How to delete default minimize and maximize button of window using c#.
Add namespaces : using System.Windows.Interop; using System.Runtime.InteropServices;
public Window1()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
RemoveControlBoxes();
}
[DllImport("User32.dll", EntryPoint = "GetWindowLong")]
private extern static Int32 GetWindowLongPtr(IntPtr hWnd, Int32 nIndex);
[DllImport("User32.dll", EntryPoint = "SetWindowLong")]
private extern static Int32 SetWindowLongPtr(IntPtr hWnd, Int32 nIndex, Int32 dwNewLong);
private const Int32 GWL_STYLE = -16;
private void RemoveControlBoxes()
{
IntPtr hWnd = new WindowInteropHelper(this).Handle;
long WindowLong = GetWindowLongPtr(hWnd, GWL_STYLE);
WindowLong = WindowLong & -131073 [...]