提出问题提出问题
 

已答复Hide Maximize/Minimze buttons?

  • 2009年7月2日 22:51Kofoed 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Is there a way to hide the max/min buttons for the window?  I know you can use ToolWindow, but I'm having some problems using that style (it gets lost in the ALT-TAB menu) so I need a different way.  And I don't really want to rewrite the window chrome or redraw the borders if I don't have to.

答案

  • 2009年7月3日 0:01noorbakhsh 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复
    Kofoed,
    If you also don't want to resize the window, a  ResizeMode="NoResize" will do it. It will remove them, but then, no resizing either.

    Hope this helps.
    noorbakhsh
    • 已标记为答案Kofoed 2009年7月6日 16:11
    •  

全部回复

  • 2009年7月3日 0:01noorbakhsh 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复
    Kofoed,
    If you also don't want to resize the window, a  ResizeMode="NoResize" will do it. It will remove them, but then, no resizing either.

    Hope this helps.
    noorbakhsh
    • 已标记为答案Kofoed 2009年7月6日 16:11
    •  
  • 2009年7月4日 6:00harjohn 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     


    Hi,

    put this line of code after InitializeComponent

    this

    .WindowStyle = WindowStyle.None;


    hope solve ur problem


    Harshad..... Always 4 U
  • 2009年7月4日 6:03harjohn 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Hi,

    put this line of code after InitializeComponent()


    this.WindowStyle = WindowStyle.None;


    Hope Solve ur Problem............

    Harshad..... Always 4 U
  • 2009年7月4日 10:18John Simmons - outlaw programmer 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    I don't understand why *all* resizing is disabled just because the min/max buttons are removed from the titlebar...


  • 2009年7月6日 16:39Zhi-Xin YeMSFT, 版主用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     包含代码
    Hi Kofoed,

    You can remove the WS_MAXIMIZEBOX and WS_MINIMIZEBOX from the window style via P/Invoke.

    [DllImport("user32.dll", SetLastError = true)]
            static extern int GetWindowLong(IntPtr hWnd, int nIndex);
    
            [DllImport("user32.dll")]
            static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
    
            private const int GWL_STYLE = -16;
            private const int WS_MINIMIZEBOX = 0x20000;
            private const int WS_MAXIMIZEBOX = 0x10000;
    
            void Window5_Loaded(object sender, RoutedEventArgs e)
            {
                IntPtr hwnd = new WindowInteropHelper(this).Handle;
    
                long windowLong = GetWindowLong(hwnd, GWL_STYLE);
    
                windowLong = windowLong &~ WS_MAXIMIZEBOX;
                windowLong = windowLong &~ WS_MINIMIZEBOX;
    
                SetWindowLong(hwnd, GWL_STYLE, (int)windowLong);
            }
    


    Best Regards,
    Zhi-Xin
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.