you have a couple of options.
1) set the FormBorderStyle to None, but would of course make the form look flat
2) use the Win32 API to disable the button, try this:
| |
imports System.Runtime.InteropServices .. .. <DllImport("user32.dll", SetLastError:=true)> private shared function GetSystemMenu(byval hWnd as IntPtr, byval revert as Integer) as IntPtr End Function <DllImport("user32.dll", SetLastError:=true)> private shared function GetMenuItemCount(byval hmenu as IntPtr) as Integer End Function <DllImport("user32.dll", SetLastError:=true)> private shared function RemoveMenu(byval hmenu as IntPtr, byval npos as Integer, byval wflags as Integer) as Integer End Function <DllImport("user32.dll", SetLastError:=true)> private shared function DrawMenuBar(byval hWnd as IntPtr) as Integer End Function private Const MF_BYPOSITION as Integer = &H400& private Const MF_DISABLED as Integer = &H2& //form load event: Dim hmenu as IntPtr = GetSystemMenu(Me.Handle, 0) Dim cnt as Integer = GetMenuItemCount(hmenu) RemoveMenu(hmenu, cnt - 1, MF_DISABLED OR MF_BYPOSITION) RemoveMenu(hmenu, cnt - 2, MF_DISABLED OR MF_BYPOSITION) DrawMenuBar(Me.Handle)
|
or try this snippet:
| |
<DllImport("user32.dll", SetLastError:=true)> private shared function GetSystemMenu(byval hwnd as long, byval bRevert as long) as Long end function <DllImport("user32.dll", SetLastError:=true)> private shared function RemoveMenu(byval hwnd as long, byval nPosition as long, byval wFlags as long) as Long end function .. //form_load event: Const SC_CLOSE = &HF060 Const MF_BYCOMMAND = &H0 Dim hMenu as Long hMenu = GetSystemMenu(Me.Handle, 0) RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND)
|
try that and see how it goes, it may not be accurate but hopefully you can fix the syntax for VB.NET as appropriate/needed since I'm trying to convert it from C#
|