-
I have two forms which I would like to keep loaded. I switch between each form by hiding one of the forms. The problem is when the user clicks on the "X" which unloads the form. I need to keep both forms loaded at all times.
It is possible to disable the "X", but is there a way to make it disappear? Is there a way to make all three disappear from a form?
Thanks
deDogs
-
Hi,
On the form properties change the ControlBox option to False. That will make all the buttons invisible.
-
-
Try this,
Private Sub Form_UnLoad()
Cancel = True
Me.Hide
End Sub
This will make the form impossible to close, and changes the "X" to act as a hide button.
Add a little extra code, in the form of a boolean, to allow the form to unload when you are exiting the program.
Something like
Private Sub Form_UnLoad()
If Not booExiting then Cancel = True
Me.Hide
End Sub
Where booExiting is set True by the Main form exit location.
Hope this helps,
Steve.
-
here is a response i think you are looking for:
in a .bas module:
Code:
Public Const MF_INSERT = &H0&
Public Const MF_REMOVE = &H1000&
Public Const SC_CLOSE = &HF060
Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Declare Function InsertMenu Lib "user32" Alias "InsertMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
then in the form_load proeedure:
Code:
RemoveMenu GetSystemMenu(hwnd, 0), SC_CLOSE, MF_REMOVE
if you want to put it back later, i have added the MF_INSERT constant for you in the public declarations section. just replace MF_REMOVE with it. happy programming!!
--michael
-
Thanks for all the information.
Thanks,
deDogs
-
Hi
It doesn't work. the Removemenu makes the "X" button disable but not remove it.
-
-
Yes, why do you NEED to make it disappear?
-
wasnt this thread started 5 years ago?
-
cant you use the vbCode Tags?