Demonstrates how to disable the close button in C#.
Disable close button
private const int SC_CLOSE = 0xF060;
private const int MF_GRAYED = 0x1;
[DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("user32.dll")]
private static extern int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable);
private void Form1_Load(object sender, System.EventArgs e)
{
EnableMenuItem(GetSystemMenu(this.Handle, false), SC_CLOSE, MF_GRAYED);
}
wolflake 0 Unverified User
stribijev 0 Newbie Poster
v_sirigiri 0 Newbie Poster
alegn 0 Newbie Poster
v_sirigiri 0 Newbie Poster
eURe 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.