me.visible = false problem

Hi

I've tried this code in my main form(during form_load), but the form keeps visible.

Anyone know how to make it invisible?

Tnx in advance.

[166 byte] By [SnakeSV] at [2007-12-26]
# 1
Try overriding SetVisibleCore(). For example, this form displays itself after a 2 second delay:

Public Class Form1
Private mAllowVisible As Boolean
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Timer1.Enabled = True
Timer1.Interval = 2000
End Sub
Protected Overrides Sub SetVisibleCore(ByVal value As Boolean)
If Not mAllowVisible Then value = False
MyBase.SetVisibleCore(value)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
mAllowVisible = True
Visible = True
End Sub
End Class

nobugz at 2007-9-4 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2

If this is your main form then I would suggest simply minimizing it as the first line in your load:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Me.WindowState = FormWindowState.Minimized

End Sub

If it is not the startup form you can immediately hide the form during load:

Private Sub Form3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Me.Hide()

End Sub

I guess a better question would be what are you trying to accomplish...Why "show" a form to immediately make it not visable

DMan1 at 2007-9-4 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3

Hi there,

Rather than trying to do this in Form_Load try doing it in Form_Activate.. Another posibility is using ShowWindow API with SW_HIDE and hWnd as the parameter will definitely work..

If this helped you pls mark as answered

ahmadifx at 2007-9-4 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...