2012-03-06 29 views

Respuesta

26

Usted puede establecer la propiedad MaximizeBox de la forma en false

+1

1 Wow, yo no creo que esto iba a funcionar pero lo hace. Bonito. –

+0

botón No pensé que hacer esto, ya que el hacer clic en 'caja maximizar' ya estaba oculto en este borderstyle. –

+2

Dont ayuda con DoubleClick para mí – Petr

17

Puede desactivar el mensaje de doble clic en una barra de título en general (o cambiar el comportamiento predeterminado que se maximiza la ventana). funciona en cualquier FormBorderStyle:

private const int WM_NCLBUTTONDBLCLK = 0x00A3; //double click on a title bar a.k.a. non-client area of the form 

     protected override void WndProc(ref Message m) 
     { 
      if (m.Msg == WM_NCLBUTTONDBLCLK) 
      { 
       m.Result = IntPtr.Zero; 
       return; 
      } 
      base.WndProc(ref m); 
     } 

MSDN Source

Salud!

+0

1+ para los trabajos en doble clic escenario –

8

/// /// Esto es que estamos anulando el procedimiento básico de la ventana WIN32 para evitar que el formulario sea movido por el mouse, así como cambiar el tamaño con el doble clic del mouse. /// ///

protected override void WndProc(ref Message m) 
    { 
     const int WM_SYSCOMMAND = 0x0112; 
     const int SC_MOVE = 0xF010; 
     const int WM_NCLBUTTONDBLCLK = 0x00A3; //double click on a title bar a.k.a. non-client area of the form 

     switch (m.Msg) 
     { 
      case WM_SYSCOMMAND:    //preventing the form from being moved by the mouse. 
       int command = m.WParam.ToInt32() & 0xfff0; 
       if (command == SC_MOVE) 
        return; 
       break; 
     } 

     if(m.Msg== WM_NCLBUTTONDBLCLK)  //preventing the form being resized by the mouse double click on the title bar. 
     { 
      m.Result = IntPtr.Zero;     
      return;     
     } 

     base.WndProc(ref m); 
    } 
+0

1+ para los trabajos en doble clic escenario –

3

Sé que llego tarde a la fiesta, puede ayudar a alguien que está en busca de la misma.

private const int WM_NCLBUTTONDBLCLK = 0x00A3; //double click on a title bar a.k.a. non-client area of the form 

private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) 
{ 

    switch (msg) 
    {     
     case WM_NCLBUTTONDBLCLK: //preventing the form being resized by the mouse double click on the title bar. 
      handled = true; 
      break;     
     default: 
      break; 
    } 
    return IntPtr.Zero; 
} 
1

Acabo de comprobarlo en VB.Net. Debajo del código funcionó para mí.

Private Const Win_FormTitleDoubleClick As Integer = 163 

Protected Overrides Sub WndProc(ByRef m As Message) 
    If m.Msg = Win_FormTitleDoubleClick Then 
     m.Result = IntPtr.Zero 
     Return 
    End If 
    MyBase.WndProc(m) 
End Sub 

Nota: 163 es el código de evento

Cuestiones relacionadas