G
Guest
I want to prevent a form from closing when the user clicks the form's Close button in the form's ControlBox (i.e., the button with the "X" in the upper-right corner of the form). Instead, I just want to hide the form. My idea is to do something like the following
Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs
e.Cancel = Tru
MyBase.OnClosing(e
Me.Visible = Fals
End Su
This technique seems to work fine if the form is shown as a modeless dialog (i.e., via Form.Show). But, if I show the form as a modal dialog (i.e., via Form.ShowDialog) then the form's controls become corrupt after the form is hidden (by the user clicking the Cancel ControlBox button) and then reshown (by calling the form's ShowDialog method). Note that I need to show the form as a modal dialog
The corruption is most apparent for controls that inherit from ButtonBase and have their FlatStyle property set to Flat. In this case, when the form is reshown the controls' graphics freeze in the "MouseOver" state
I imagine that I must be doing something wrong. Any advice
Thanks
Lance
Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs
e.Cancel = Tru
MyBase.OnClosing(e
Me.Visible = Fals
End Su
This technique seems to work fine if the form is shown as a modeless dialog (i.e., via Form.Show). But, if I show the form as a modal dialog (i.e., via Form.ShowDialog) then the form's controls become corrupt after the form is hidden (by the user clicking the Cancel ControlBox button) and then reshown (by calling the form's ShowDialog method). Note that I need to show the form as a modal dialog
The corruption is most apparent for controls that inherit from ButtonBase and have their FlatStyle property set to Flat. In this case, when the form is reshown the controls' graphics freeze in the "MouseOver" state
I imagine that I must be doing something wrong. Any advice
Thanks
Lance