Problem with NotifyIcon

J

Julien [CNSX]

Hi,

I have a little problem with a VB.NET application (win2k with .NET 1.1)...

My application have :
=>a NotifyIcon with an ContextMenu, on which the user could open a winform
=>a timer which open the same winform

These two components use the same method in the same class to open the
winform.
But, by the NotifyIcon, the winform is open and close immediatly without the
time for me to act with it...
But with the timer, there is no problem, the winform open and I could make
what I want with it...

Could somebody help me?

[I'm french, so I try to be as clear as possible ;-) ]

Thanks in advance... ;-)
 
P

Phil Price

Julien said:
Hi,

I have a little problem with a VB.NET application (win2k with .NET
1.1)...

My application have :
=>a NotifyIcon with an ContextMenu, on which the user could open a
winform =>a timer which open the same winform

These two components use the same method in the same class to open the
winform.
But, by the NotifyIcon, the winform is open and close immediatly
without the time for me to act with it...
But with the timer, there is no problem, the winform open and I could
make what I want with it...

I'm not really sure what you want, but Im guessing its to do with the
notify icon, context menus and a winform behavind badly? Anyway take a
look at http://www.philprice.net/dotnet/qblogger/ you can pick up the
source there, its just a fun little application for blogging I made (to
learn .NET).

Peace,
 
J

Julien [CNSX]

Thanks for your reply but I have already seen this solution and it don't
solve my problem because the UI of the winform, I want to load, is make
dinamycally in according to the value I have in my DataBase...

I put part of my code to explain what I mean :

'Déclaration de MenuItem du ContextMenu pour la NotifyIcon
Dim oMenuDis As New MenuItem("Lancer", New EventHandler(AddressOf
DisplayMenuClick))
oMenu.MenuItems.Add(oMenuDis)
oIcone.ContextMenu = oMenu
....

'Method call on the click to the ContextMenu of the NotifyIcon
Private Sub DisplayMenuClick(ByVal Sender As Object, ByVal e As EventArgs)
OpenDownloadForm()
End Sub

'TIMER
Private Sub timer_Tick(ByVal sender As Object, ByVal timerEvents As
System.Timers.ElapsedEventArgs) Handles timer.Elapsed
OpenDownloadForm()
End Sub

Private Sub OpenDownloadForm()
if oDownloadForm is nothing then
'affichage des download à effectuer
oDownloadForm = new DownloadForm
oDownloadForm.ShowDialog(Me)
oDownloadForm = Nothing
End If
end sub
 
N

NotYetaNurd

what value have you given for property tick in timer...


Julien said:
I continue to work on this problem and I want to share with you my
"advance"...

I have delete the timer of the winform and the application run great...so, I
suppose there is a "conflict" between the timer and the ContextMenu, but I
don't know why??? :-((

Julien said:
Thanks for your reply but I have already seen this solution and it don't
solve my problem because the UI of the winform, I want to load, is make
dinamycally in according to the value I have in my DataBase...

I put part of my code to explain what I mean :

'Déclaration de MenuItem du ContextMenu pour la NotifyIcon
Dim oMenuDis As New MenuItem("Lancer", New EventHandler(AddressOf
DisplayMenuClick))
oMenu.MenuItems.Add(oMenuDis)
oIcone.ContextMenu = oMenu
...

'Method call on the click to the ContextMenu of the NotifyIcon
Private Sub DisplayMenuClick(ByVal Sender As Object, ByVal e As EventArgs)
OpenDownloadForm()
End Sub

'TIMER
Private Sub timer_Tick(ByVal sender As Object, ByVal timerEvents As
System.Timers.ElapsedEventArgs) Handles timer.Elapsed
OpenDownloadForm()
End Sub

Private Sub OpenDownloadForm()
if oDownloadForm is nothing then
'affichage des download à effectuer
oDownloadForm = new DownloadForm
oDownloadForm.ShowDialog(Me)
oDownloadForm = Nothing
End If
end sub


Phil Price said:
Julien [CNSX] wrote:

Hi,

I have a little problem with a VB.NET application (win2k with .NET
1.1)...

My application have :
=>a NotifyIcon with an ContextMenu, on which the user could open a
winform =>a timer which open the same winform

These two components use the same method in the same class to open the
winform.
But, by the NotifyIcon, the winform is open and close immediatly
without the time for me to act with it...
But with the timer, there is no problem, the winform open and I could
make what I want with it...

I'm not really sure what you want, but Im guessing its to do with the
notify icon, context menus and a winform behavind badly? Anyway take a
look at http://www.philprice.net/dotnet/qblogger/ you can pick up the
source there, its just a fun little application for blogging I made (to
learn .NET).

Peace,

--
Phil Price
Student at The University Of Hull
http://www.philprice.net
http://www.dcs.hull.ac.uk
 
J

Julien [CNSX]

Thanks for your help...

But I solve the problem using a System.Threading.Mutex, a
System.Threading.Timer and a Thread for the NotifyIcon ContextMenu...

All these thread waiting for the mutex, so it can't be the winform to be
open twice ;-)

NotYetaNurd said:
what value have you given for property tick in timer...


Julien said:
I continue to work on this problem and I want to share with you my
"advance"...

I have delete the timer of the winform and the application run
great...so,
I
suppose there is a "conflict" between the timer and the ContextMenu, but I
don't know why??? :-((

Julien said:
Thanks for your reply but I have already seen this solution and it don't
solve my problem because the UI of the winform, I want to load, is make
dinamycally in according to the value I have in my DataBase...

I put part of my code to explain what I mean :

'Déclaration de MenuItem du ContextMenu pour la NotifyIcon
Dim oMenuDis As New MenuItem("Lancer", New EventHandler(AddressOf
DisplayMenuClick))
oMenu.MenuItems.Add(oMenuDis)
oIcone.ContextMenu = oMenu
...

'Method call on the click to the ContextMenu of the NotifyIcon
Private Sub DisplayMenuClick(ByVal Sender As Object, ByVal e As EventArgs)
OpenDownloadForm()
End Sub

'TIMER
Private Sub timer_Tick(ByVal sender As Object, ByVal timerEvents As
System.Timers.ElapsedEventArgs) Handles timer.Elapsed
OpenDownloadForm()
End Sub

Private Sub OpenDownloadForm()
if oDownloadForm is nothing then
'affichage des download à effectuer
oDownloadForm = new DownloadForm
oDownloadForm.ShowDialog(Me)
oDownloadForm = Nothing
End If
end sub


"Phil Price" <[email protected]> a écrit dans le message de
Julien [CNSX] wrote:

Hi,

I have a little problem with a VB.NET application (win2k with .NET
1.1)...

My application have :
=>a NotifyIcon with an ContextMenu, on which the user could open a
winform =>a timer which open the same winform

These two components use the same method in the same class to open the
winform.
But, by the NotifyIcon, the winform is open and close immediatly
without the time for me to act with it...
But with the timer, there is no problem, the winform open and I could
make what I want with it...

I'm not really sure what you want, but Im guessing its to do with the
notify icon, context menus and a winform behavind badly? Anyway take a
look at http://www.philprice.net/dotnet/qblogger/ you can pick up the
source there, its just a fun little application for blogging I made (to
learn .NET).

Peace,

--
Phil Price
Student at The University Of Hull
http://www.philprice.net
http://www.dcs.hull.ac.uk
 

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