Soumen-Roy
asked on
C# to VB.Net
Hi Experts,
I am using the following code in VB.Net to use notify icon in my WPF application. I am using Win 7 64 Bit.
========================== ========== ========== ========== =
Friend WithEvents NotIco As System.Windows.Forms.Notif yIcon
Private Sub Window_Initialized(sender As System.Object, e As System.EventArgs) Handles MyBase.Initialized
Dim IcoPath As String
IcoPath = My.Settings.ApplicationIco nPathWithI conName
NotIco = New System.Windows.Forms.Notif yIcon()
NotIco.Icon = New System.Drawing.Icon(IcoPat h)
NotIco.Visible = True
End Sub
========================== ========== ========== ========== ========== =
Now I have 2 questions.
1. How to write the following line in VB.Net?
NotIco.MouseClick += new System.Windows.Forms.Mouse EventHandl er(NotIco_ MouseClick );
If I write NotIco & then press "." no MouseClick event is there in the autocomplete lict box. How to do it?
2. If I use notify icon in WPF like this way, will it be a problem in XP SP3?
Please help,
Soumen
I am using the following code in VB.Net to use notify icon in my WPF application. I am using Win 7 64 Bit.
==========================
Friend WithEvents NotIco As System.Windows.Forms.Notif
Private Sub Window_Initialized(sender As System.Object, e As System.EventArgs) Handles MyBase.Initialized
Dim IcoPath As String
IcoPath = My.Settings.ApplicationIco
NotIco = New System.Windows.Forms.Notif
NotIco.Icon = New System.Drawing.Icon(IcoPat
NotIco.Visible = True
End Sub
==========================
Now I have 2 questions.
1. How to write the following line in VB.Net?
NotIco.MouseClick += new System.Windows.Forms.Mouse
If I write NotIco & then press "." no MouseClick event is there in the autocomplete lict box. How to do it?
2. If I use notify icon in WPF like this way, will it be a problem in XP SP3?
Please help,
Soumen
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For issue 1, type:
AddHandler NotIco.
Now the MouseClick will be there.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@robert_schutt:
As per your suggestion my code is as follows:
Friend WithEvents NotIco As System.Windows.Forms.Notif yIcon
Private Sub Window_Initialized(sender As System.Object, e As System.EventArgs) Handles MyBase.Initialized
Dim IcoPath As String
IcoPath = My.Settings.ApplicationIco nPathWithI conName
NotIco = New System.Windows.Forms.Notif yIcon()
NotIco.Icon = New System.Drawing.Icon(IcoPat h)
NotIco.Visible = True
NotIco.AddHandler
End Sub
But it is throwing error at the end of AddHandler, it expects a comma na d probably some more thing. Can you please a little elaborative?
Regards,
Soumen
As per your suggestion my code is as follows:
Friend WithEvents NotIco As System.Windows.Forms.Notif
Private Sub Window_Initialized(sender As System.Object, e As System.EventArgs) Handles MyBase.Initialized
Dim IcoPath As String
IcoPath = My.Settings.ApplicationIco
NotIco = New System.Windows.Forms.Notif
NotIco.Icon = New System.Drawing.Icon(IcoPat
NotIco.Visible = True
NotIco.AddHandler
End Sub
But it is throwing error at the end of AddHandler, it expects a comma na d probably some more thing. Can you please a little elaborative?
Regards,
Soumen
my first post specified the dot so you would see the property being shown.
my second post specified the whole line.
my second post specified the whole line.
o, I just saw your error: "NotIco.AddHandler" is not what I posted.
ASKER
@robert_schutt:
Thanx a lot, it worked :-).
Regards,
Soumen
Thanx a lot, it worked :-).
Regards,
Soumen
ASKER
Thanx Exterts,
You solved my problem nicely.
Regards,
Soumen
You solved my problem nicely.
Regards,
Soumen
Maybe this is not applicable for you because you just want to convert the code but normally the easier way to implement an event handler in VB.NET is to go to the form, click on the component (NotifyIcon will be at the bottom), go to properties (F4), then click on the lightning bolt icon at the top for events and double click in the value field for the event you want to handle. Here's another picture.
ASKER
I have gone through that link. I wanted to know how to convert that C# line to VB.Net as MouseClick is not available after "." in VB.Net