By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,360 Members | 3,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,360 IT Pros & Developers. It's quick & easy.

NotifyIcon.DoubleClick/.Click doesn't work in Console App

P: 3
Hi everyone...

I'm a starter at .Net programming, and I need some help.

I was asked to develop a console app that will auto-hide the console window and show a system tray icon.

And by default, the system tray icon on click is supposed to show the console window

I know window apps are usually the better solution for handling NotifyIcon class, but I would really like to know how to do it in console apps

here are my codes:

'declaring the object
Dim WithEvents NotifyIcon1 As New NotifyIcon

'initializing
NotifyIcon1.Icon = New System.Drawing.Icon("C:\Documents and Settings\achan\My Documents\Icon.ico")

'setting icon to visible on execute
NotifyIcon1.Visible = True

'adding event handler
AddHandler NotifyIcon1.DoubleClick, AddressOf NotifyIcon_DoubleClick

'method to be executed on event
Private Sub NotifyIcon_DoubleClick(ByVal source As Object, ByVal e As EventArgs) Handles NotifyIcon1.Click
If NotifyIcon1.Visible = True Then
ShowWindow(winHandle, SHOW_WINDOW.SW_NORMAL)
NotifyIcon1.Visible = False

Else
ShowWindow(winHandle, SHOW_WINDOW.SW_HIDE)
NotifyIcon1.Visible = True
End If
End Sub

Basically.. that's all for what I have regarding the NotifyIcon classes. In this case, my ShowWindow method is working nicely, so I have absolutely no idea how to solve the problem.

Also, I tried using the MouseEventsArgs but it doesn't work. No matter what I do with the NotifyIcon, it doesn't respond on any mouse clicks.

Any and all help will be very much appreciated.


Please pardon me if this was posted at the wrong forum
Apr 2 '07 #1
Share this Question
Share on Google+
5 Replies


kenobewan
Expert 2.5K+
P: 4,871
Welcome to the site. Here is a thread that may help:
datagrid event
Apr 2 '07 #2

P: 3
Hi... Thanks for the link, but it's not helping.

Basically... the system tray icon just ends up being a static icon. I can't show the console window when the user clicks.
Apr 3 '07 #3

Motoma
Expert 2.5K+
P: 3,235
Hi... Thanks for the link, but it's not helping.

Basically... the system tray icon just ends up being a static icon. I can't show the console window when the user clicks.
Is the NotifyIcon_DoubleClick sub being called?
Apr 3 '07 #4

P: 3
Is the NotifyIcon_DoubleClick sub being called?

Expand|Select|Wrap|Line Numbers
  1. 'adding event handler
  2. AddHandler NotifyIcon1.DoubleClick, AddressOf NotifyIcon_DoubleClick
Hi... Thanks for replying. Really appreciate it. I added an event handler, and thought it will call the NotifyIcon_DoubleClick method on double clicking the icon. Did I miss something out?
Apr 3 '07 #5

Motoma
Expert 2.5K+
P: 3,235
Expand|Select|Wrap|Line Numbers
  1. 'adding event handler
  2. AddHandler NotifyIcon1.DoubleClick, AddressOf NotifyIcon_DoubleClick
Hi... Thanks for replying. Really appreciate it. I added an event handler, and thought it will call the NotifyIcon_DoubleClick method on double clicking the icon. Did I miss something out?
Yes, it looks like that should happen, but is it?
Try tracing through your code, or adding a popup box inside the subroutine.
Apr 3 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.