[Quote=引用 7 楼 xingyuebuyu 的回复:]
Public Class Form1
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Dim WM_SYSCOMMAND As Integer = &H112
Dim SC_CLOSE As Integer = &HF060
Public Class Form1
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Dim WM_SYSCOMMAND As Integer = &H112
Dim SC_CLOSE As Integer = &HF060
If m.Msg = WM_SYSCOMMAND AndAlso CInt(m.WParam) = SC_CLOSE Then
''运行到这里就是点右上角的X来关闭的,下面的return就是不处理这个消息,也就是点X不能关闭窗体;
Return
End If
MyBase.WndProc(m)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
''关闭窗体
Me.Close()
End Sub
End Class