Solved

C# to VB.Net

Posted on 2013-01-19
11
555 Views
Last Modified: 2013-01-19
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.NotifyIcon

Private Sub Window_Initialized(sender As System.Object, e As System.EventArgs) Handles MyBase.Initialized
        Dim IcoPath As String

        IcoPath = My.Settings.ApplicationIconPathWithIconName
        NotIco = New System.Windows.Forms.NotifyIcon()
        NotIco.Icon = New System.Drawing.Icon(IcoPath)
        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.MouseEventHandler(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
0
Comment
Question by:Soumen-Roy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 9

Assisted Solution

by:sognoct
sognoct earned 100 total points
ID: 38796176
don't have vs2010 here but I've found this interesting article :

http://www.codeproject.com/Articles/36468/WPF-NotifyIcon

I never had any problem in running wpf application on xp sp3 right now ...
0
 

Author Comment

by:Soumen-Roy
ID: 38796197
@sognoct

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
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 38796237
For issue 1, type:
AddHandler NotIco.

Open in new window

Now the MouseClick will be there.
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 35

Accepted Solution

by:
Robert Schutt earned 400 total points
ID: 38796242
The full line will be:
AddHandler NotIco.MouseClick, AddressOf NotIco_MouseClick

Open in new window

0
 

Author Comment

by:Soumen-Roy
ID: 38796247
@robert_schutt:

As per your suggestion my code is as follows:

Friend WithEvents NotIco As System.Windows.Forms.NotifyIcon

Private Sub Window_Initialized(sender As System.Object, e As System.EventArgs) Handles MyBase.Initialized
        Dim IcoPath As String

        IcoPath = My.Settings.ApplicationIconPathWithIconName
        NotIco = New System.Windows.Forms.NotifyIcon()
        NotIco.Icon = New System.Drawing.Icon(IcoPath)
        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
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 38796306
my first post specified the dot so you would see the property being shown.

my second post specified the whole line.
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 38796307
o, I just saw your error: "NotIco.AddHandler" is not what I posted.
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 38796317
here's how it looks for me:
captures
0
 

Author Comment

by:Soumen-Roy
ID: 38796335
@robert_schutt:

Thanx a lot, it worked :-).

Regards,
Soumen
0
 

Author Closing Comment

by:Soumen-Roy
ID: 38796342
Thanx Exterts,

You solved my problem nicely.

Regards,
Soumen
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 38796347
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.capture2
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question