0

I am trying to delete "X"/ Close button on the right side of the WPF window. I tried researching a lot about it on internet and came across 2 methods of doing it.

  1. Completely removing the title bar by using GetWindowLong and SetWindowLong using solution posted in this post. How to hide close button in WPF window? Problem - this method removes the complete System menu(buttons of right side + Icon on left side) and I don't want ICON to disappear.
  2. Used GetSystemMenu,RemoveMenu Problem - this method only disables/grays out the X button although it keeps the ICON but doesn't remove the X button.

Can someone please help me with this issue?

Community
  • 1
  • 1
Jignesh
  • 136
  • 2
  • 9
  • Hi mydogisbox, the post that you have mentioned is similar to the one that i have in my question and all replies over there are related to disabling the button and not deleting it completely. Please correct me if i am wrong. – Jignesh Nov 17 '11 at 17:38
  • It's my understanding that you want the close button to not show. The answer to the linked post does exactly that. – N_A Nov 17 '11 at 17:59
  • mydogisbox is correct, it completely removes the close button, not just disables. additionally, window icon and system menu are removed as side effect. – Emir Akaydın Nov 17 '11 at 18:08
  • 1
    @Jignesh I think the problem is your understanding of the linked answer. It does NOT remove the title bar. What it does do is remove the close button and the windows icon on the left side of the title bar/the system menu. If you want to remove the close button but not the windows icon/system menu then you're just out of luck. – N_A Nov 17 '11 at 18:15
  • @mydogisbox, Thanks for your replies guys. Actually i understood the link correctly but probably used incorrect words(title bar i should have said system menu my apologies for creating confusion). I got the whole point that it removes the system menu along with ICON whereas what i want was to remove system Menu but keep icon. But as you said if it cannot be done then i might have to leave it as it is. thanks for your time and replies guys..... – Jignesh Nov 17 '11 at 19:26

1 Answers1

2

You need to create your own chrome, add the buttons for minimize, maximize, close, etc, and disable the close button. You need to provide code for all the other functions, such as dragging area, context menus for moving, etc. Not too much and it will get you exactly what you want.

Gus Cavalcanti
  • 10,527
  • 23
  • 71
  • 104