none
WPF Window remove icon, minimize & maximize button

    Question

  • Hey guys!

    I need to remove a wpf window's icon, minimize and maximize box.
    I already managed that with the win32 api calls:
    int extendedStyle=GetWindowLong(hwnd, GWL_EXSTYLE);
    SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_DLGMODALFRAME);
    
    if (!ShowMinMax)
    {
      int windowLong=GetWindowLong(hwnd, GWL_STYLE);
      windowLong=windowLong&WS_MINIMIZE_INV&WS_MAXIMIZE_INV;
      SetWindowLong(hwnd, GWL_STYLE, windowLong);
    }
    This works fine when the target system runs under the same dpi settings as my machine does. Nevertheless when the target machine is running under a higher dpi the window is too small -> the calls seem to destroy the benefits of wpf (it also seem that the width and height set are no more longer device independent values but pixels?)

    Any way to make the wanted controls vanish using wpf calls only?

    Thanks in advance
    trust is a weakness, betrayal is the hidden blade
    Friday, September 11, 2009 7:15 AM

Answers

All replies

  • Hi,
    Try windowstyle.none property
    Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
    Friday, September 11, 2009 7:22 AM
  • I don't want the border and the title to disappear... just the buttons i don't need (as in windows forms)
    trust is a weakness, betrayal is the hidden blade
    Friday, September 11, 2009 7:24 AM
  • Hi,
    Have a look at this link

    http://social.msdn.microsoft.com/forums/en-US/wpf/thread/d74820db-a002-4d4e-b96e-02d29dc4a119/
    Best Regards, C.Gnanadurai ----------------------- Please mark the post as answer if it is helpfull to you
    • Marked as answer by Jim Zhou - MSFT Wednesday, September 16, 2009 8:37 AM
    Friday, September 11, 2009 10:20 AM
  • Hi NeoKenshinX,

    You can remove the minimize and the maximize button via setting ResizeMode to NoResize as Gnanadurai said, but for removing the icon and close button, the is no direct way. I recommend you can create your own template for Window(with WindowStyle.None setting), and you can reuse it. Since WPF is pixel and device independent, you will not need to worry when running in a high or a low DPI setting environment.
    Thanks.
    Sincerely.
    Jim Zhou -MSFT
    Monday, September 14, 2009 10:17 AM
  • you should set following window property. It will remove minimize and maximise button and only left with close button.

    ResizeMode = "NoResize"

    • Proposed as answer by convey2ankur Tuesday, September 06, 2011 11:29 AM
    • Edited by convey2ankur Tuesday, September 06, 2011 11:29 AM update to view text properly.
    Tuesday, September 06, 2011 11:28 AM