We often need to implement the "user closes the form, but the form is not closed but minimized" function. The implementation of this function is very simple, you only need to write the following in the formclosing eventCodeYou can:
If E. closereason = closereason. userclosing then 'is used to determine whether the form is closed by the user.
E. Cancel = true'ProgramStop closing
End if
The "if E. closereason = closereason. userclosing then" clause is used to determine whether the form is closed by the user.
Why is this judgment necessary? There are three sources for the "close form" Operation: User, other programs, and Windows system, such as shutdown and restart, in Windows, the program opened by the user is closed.If this condition is not added, the windows program cannot be closed before it is shut down and restarted, so the Windows system is stuck when it is shut down and restarted. Therefore, XP cannot be restarted after it is shut down (XP and win7 are unavailable ).
Thank you, a friend named Chen Feng, for proposing the bug "convenient master Quick Start tool" to me. After research, this problem has been resolved as mentioned above.