Poser une questionPoser une question
 

TraitéeHide Maximize/Minimze buttons?

  • jeudi 2 juillet 2009 22:51Kofoed Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    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.

Réponses

  • vendredi 3 juillet 2009 00:01noorbakhsh Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée
    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
    • Marqué comme réponseKofoed lundi 6 juillet 2009 16:11
    •  

Toutes les réponses

  • vendredi 3 juillet 2009 00:01noorbakhsh Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     Traitée
    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
    • Marqué comme réponseKofoed lundi 6 juillet 2009 16:11
    •  
  • samedi 4 juillet 2009 06:00harjohn Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     


    Hi,

    put this line of code after InitializeComponent

    this

    .WindowStyle = WindowStyle.None;


    hope solve ur problem


    Harshad..... Always 4 U
  • samedi 4 juillet 2009 06:03harjohn Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    Hi,

    put this line of code after InitializeComponent()


    this.WindowStyle = WindowStyle.None;


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

    Harshad..... Always 4 U
  • samedi 4 juillet 2009 10:18John Simmons - outlaw programmer Médailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    I don't understand why *all* resizing is disabled just because the min/max buttons are removed from the titlebar...


  • lundi 6 juillet 2009 16:39Zhi-Xin YeMSFT, ModérateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     A du code
    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.