In fact, the three buttons on the upper right side of the Form correspond to several options in the ControlBox (ControlBox) on the upper left side of the Form (minimize/maximize/close), among which the maximize (MaxButton) and minimize (Minbutton) They can be set directly in the properties of the Form, but VB does not provide the function of setting the "X" button! To achieve this function, you must use API:
Since the "X" button corresponds to the close option of ControlBox, we only need to remove the close option of the system Menu (that is, ControlBox)! You can first take a look at the system menu in the upper left corner of the Browser you are using. Which number is the [Close] option, not the 6th one? It’s the 7th one, and the dividing line counts as one! The divider is the 6th one!
When we remove the close option, a strange separator line will be left, so it’s best to remove the separator line as well. The Menu's Index starts from 0, and the dividing line is the 6th one, so Index=5.
Correction: In order to make the program code work properly on Windows NT, change the Integer type to Long. 89.05.04
'Catch the hwnd of the system Menu
PRivateDeclareFunctionGetSystemMenuLib"user32"Alias"GetSystemMenu"(ByValhwndAsLong,ByValbRevertAsLong)AsLong
'Remove system Menu API
PrivateDeclareFunctionRemoveMenuLib"user32"Alias"RemoveMenu"(ByValhMenuAsLong,ByValnPositionAsLong,ByValwFlagsAsLong)AsLong
'The first parameter is the hwnd of the system Menu
'The second parameter is the Index-> of the option to be removed