Window Activiation Causes Controls to Disappear

M

Mitchell Vincent

I have a tiny little application that runs, and when minimized it throws
itself into the systray until the user double clicks on the systray
icon. To accomplish that first part I have this :

Private Sub frmMain_Resize(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles MyBase.Resize
If Me.WindowState = FormWindowState.Minimized Then
Me.Visible = False
Me.ShowInTaskbar = False
End If
End Sub

... I hope that is correct, it does seem to work.

To show the window again on double click of the icon I have :

Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e
As System.EventArgs) Handles NotifyIcon1.DoubleClick

Me.Visible = True
Me.ShowInTaskbar = True
Me.Activate()

If Me.WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Normal
End If

End Sub

However, the panel and the 2 web browser controls on the panel are
hidden and never show up again..

What am I doing (or not doing!)?
 
P

Peter Huang [MSFT]

Hi

Thanks for using Microsoft MSDN Managed Newsgroup. My name is Peter, and I
will be assisting you on this issue.
First of all, I would like to confirm my understanding of your issue.
From your description, I understand that after minimized the app into
systray and reactive it the component on the form is invisible.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think you may try the code below.
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize
If Me.WindowState = FormWindowState.Minimized Then
Me.Visible = False
Me.ShowInTaskbar = False
End If
End Sub


Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles NotifyIcon1.DoubleClick
Me.ShowInTaskbar = True
Me.Visible = True
Me.Activate()

If Me.WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Normal
End If
End Sub

Also I think the Me.Visible = False is not necessary you may try to comment
out it to see if that met your request.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mitchell Vincent

Peter said:
Also I think the Me.Visible = False is not necessary you may try to comment
out it to see if that met your request.

Best regards,

Peter Huang
Microsoft Online Partner Support

Yes, Peter, you understood my question exactly and your suggestion
worked! The Window now appears normally when it is restored. However,
this seems to have caused another problem. When I set ShowInTaskBar to
false, it still shows some kind of "ghost" window on the taskbar. It
does not react when clicked but every time the app is minimized (and an
icon put in the systray) it appears. Is there some other trick to
getting it to not show in the taskbar other than me.ShowInTaskbar = False ?

THANKS!
 
P

Peter Huang [MSFT]

Hi

Thanks for your quickly reply!

So far the ShowInTaskbar is the managed way to do control if the windows
showed in taskbar.
Also can you provide a simple reproduce sample, compress to a zip file and
add it as an attachment in the newsgroup so that I can do further
troubleshooting and try to find how to workaround the problem.

Thanks!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang [MSFT]

Hi

Thank for your reproduce sample.
I can reproduce the problem with your code.
So far as a workaround I think we may try to set the ShowInTaskBar property
to false in the design time and change the code as below.
Dim loginURL As String = "http://www.google.com"

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AxWebBrowser1.Navigate2(loginURL)
End Sub

Private Sub frmMain_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Resize
'If Me.WindowState = FormWindowState.Minimized Then
' Me.Visible = False
' Me.ShowInTaskbar = False
'End If
End Sub

Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles NotifyIcon1.DoubleClick
If Me.WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Normal
End If
Me.Activate()
End Sub

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mitchell Vincent

Peter said:
Hi

Thank for your reproduce sample.
I can reproduce the problem with your code.
So far as a workaround I think we may try to set the ShowInTaskBar property
to false in the design time and change the code as below.

Thanks Peter, I appreciate you looking at this.. However, I would really
like to keep the software in the taskbar until it is minimized, just to
keep the "standard". That is the simplest example I could find and it
doesn't seem to work. Is no one using .NET to do this? Seems like a
pretty big bug to me!

Thanks again!
 
P

Peter Huang [MSFT]

Hi

Thanks for your quickly reply!

So far we are researching the issue, and we will update you with new
information ASAP.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang [MSFT]

Hi

I reviewed the thread and find that there is a similar issue in the
newsgroup below.Now our colleague has replied to you, you may go and take a
look.
Subject: ShowInTaskBar = False just doesn't work?
Newsgroups: microsoft.public.dotnet.general

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mitchell Vincent

Peter said:
Hi

I reviewed the thread and find that there is a similar issue in the
newsgroup below.Now our colleague has replied to you, you may go and take a
look.
Subject: ShowInTaskBar = False just doesn't work?
Newsgroups: microsoft.public.dotnet.general

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

They've pointed me in the right direction for sure! I'm waiting on some
additional information on that thread. I might have to leave .NET for
this because of the lack of control for ActiveX controls, but we'll see..

Thanks Peter!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top