2

Can anyone tell me how to remove the close (X) button from a WPF window? I can disable it by following code but can not remove it:

    private const uint SC_CLOSE = 0xF060; 
    [DllImport("user32.dll")] 
    private static extern IntPtr GetSystemMenu(IntPtr hwnd, bool revert); 
    [DllImport("user32.dll")] 
    private static extern bool DeleteMenu(IntPtr hMenu, uint position, uint flags);

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        WindowInteropHelper helper = new WindowInteropHelper(this); 

        IntPtr hwnd = GetSystemMenu(helper.Handle, false); 

        DeleteMenu(hwnd, SC_CLOSE, 0); 

    }
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
atul gupta
  • 191
  • 1
  • 4
  • 16
  • 1
    Does this answer your question? [How to hide close button in WPF window?](https://stackoverflow.com/questions/743906/how-to-hide-close-button-in-wpf-window) – StayOnTarget Aug 14 '20 at 18:52

0 Answers0