Principales respuestas
quiero desactivar la opción tamaño de esta ventana. ¿saben como?

Pregunta
-
Respuestas
-
Sí.
Obtienes el handle del menú con GetSystemMenu().
Inhabilitas el item, llamando a ModifyMenu() MF_BYCOMMAND/SC_SIZE/MF_GRAYED
using System; using System.Windows.Forms; using System.Runtime.InteropServices; namespace WindowsFormsApplication1 { public partial class Form1 : Form { private UInt32 MF_BYCOMMAND = 0; private UInt32 MF_GRAYED = 1; private UInt32 SC_SIZE = 0xF000; [DllImport("user32.dll")] private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); [DllImport("user32.dll")] private static extern bool ModifyMenu(IntPtr hMnu, UInt32 uPosition, UInt32 uFlags, IntPtr uIDNewItem, string lpNewItem); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { IntPtr sysMenu = GetSystemMenu(this.Handle, false); ModifyMenu(sysMenu, SC_SIZE, MF_BYCOMMAND | MF_GRAYED, IntPtr.Zero, "Tamaño"); } } }
Imports System.Runtime.InteropServices Partial Public Class Form1 Inherits Form Private MF_BYCOMMAND As UInt32 = 0 Private MF_GRAYED As UInt32 = 1 Private SC_SIZE As UInt32 = &HF000 <DllImport("user32.dll")> _ Private Shared Function GetSystemMenu(hWnd As IntPtr, bRevert As Boolean) As IntPtr End Function <DllImport("user32.dll")> _ Private Shared Function ModifyMenu(hMnu As IntPtr, uPosition As UInt32, uFlags As UInt32, uIDNewItem As IntPtr, lpNewItem As String) As Boolean End Function Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim sysMenu As IntPtr = GetSystemMenu(Me.Handle, False) ModifyMenu(sysMenu, SC_SIZE, MF_BYCOMMAND Or MF_GRAYED, IntPtr.Zero, "Tamaño") End Sub End Class
- Editado Pizpireta lunes, 9 de septiembre de 2013 22:07
- Marcado como respuesta mojicahaner lunes, 9 de septiembre de 2013 23:14
Todas las respuestas
-
-
Sí.
Obtienes el handle del menú con GetSystemMenu().
Inhabilitas el item, llamando a ModifyMenu() MF_BYCOMMAND/SC_SIZE/MF_GRAYED
using System; using System.Windows.Forms; using System.Runtime.InteropServices; namespace WindowsFormsApplication1 { public partial class Form1 : Form { private UInt32 MF_BYCOMMAND = 0; private UInt32 MF_GRAYED = 1; private UInt32 SC_SIZE = 0xF000; [DllImport("user32.dll")] private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); [DllImport("user32.dll")] private static extern bool ModifyMenu(IntPtr hMnu, UInt32 uPosition, UInt32 uFlags, IntPtr uIDNewItem, string lpNewItem); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { IntPtr sysMenu = GetSystemMenu(this.Handle, false); ModifyMenu(sysMenu, SC_SIZE, MF_BYCOMMAND | MF_GRAYED, IntPtr.Zero, "Tamaño"); } } }
Imports System.Runtime.InteropServices Partial Public Class Form1 Inherits Form Private MF_BYCOMMAND As UInt32 = 0 Private MF_GRAYED As UInt32 = 1 Private SC_SIZE As UInt32 = &HF000 <DllImport("user32.dll")> _ Private Shared Function GetSystemMenu(hWnd As IntPtr, bRevert As Boolean) As IntPtr End Function <DllImport("user32.dll")> _ Private Shared Function ModifyMenu(hMnu As IntPtr, uPosition As UInt32, uFlags As UInt32, uIDNewItem As IntPtr, lpNewItem As String) As Boolean End Function Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim sysMenu As IntPtr = GetSystemMenu(Me.Handle, False) ModifyMenu(sysMenu, SC_SIZE, MF_BYCOMMAND Or MF_GRAYED, IntPtr.Zero, "Tamaño") End Sub End Class
- Editado Pizpireta lunes, 9 de septiembre de 2013 22:07
- Marcado como respuesta mojicahaner lunes, 9 de septiembre de 2013 23:14
-
-
-