473,573 Members | 2,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NotifyIcon.Doub leClick/.Click doesn't work in Console App

3 New Member
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.Ico n = New System.Drawing. Icon("C:\Docume nts and Settings\achan\ My Documents\Icon. ico")

'setting icon to visible on execute
NotifyIcon1.Vis ible = True

'adding event handler
AddHandler NotifyIcon1.Dou bleClick, AddressOf NotifyIcon_Doub leClick

'method to be executed on event
Private Sub NotifyIcon_Doub leClick(ByVal source As Object, ByVal e As EventArgs) Handles NotifyIcon1.Cli ck
If NotifyIcon1.Vis ible = True Then
ShowWindow(winH andle, SHOW_WINDOW.SW_ NORMAL)
NotifyIcon1.Vis ible = False

Else
ShowWindow(winH andle, SHOW_WINDOW.SW_ HIDE)
NotifyIcon1.Vis ible = 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
5 2887
kenobewan
4,871 Recognized Expert Specialist
Welcome to the site. Here is a thread that may help:
datagrid event
Apr 2 '07 #2
celestialgal86
3 New Member
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
3,237 Recognized Expert Specialist
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_Doub leClick sub being called?
Apr 3 '07 #4
celestialgal86
3 New Member
Is the NotifyIcon_Doub leClick 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_Doub leClick method on double clicking the icon. Did I miss something out?
Apr 3 '07 #5
Motoma
3,237 Recognized Expert Specialist
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_Doub leClick 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

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

Similar topics

0
1583
by: petterl | last post by:
I have tried to find the error in the code below but I always get " An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module. Additional information: Object reference not set to an instance of an object." and then
3
2308
by: ThunderMusic | last post by:
Hi, I'm trying to have a MSN Messenger like form/app closing behavior. When I click on the X button, I only want the form to disappear and when I double-click on the notify icon or right-click on it and choose Open from the context menu, I want the form to reappear. For that, I got the point covered. Even when the form is minimize, the...
2
513
by: Rob Mayo | last post by:
OK, maybe this is my opinion, maybe these are bugs. Given the folowing: I have a NotifyIcon on my Form, a Context menu associated with the NotifyIcon, and a MenuItem on the ContextMenu set as default. When the default MenuItem is clicked, there is code to no longer show the NotifyIcon. What I feel should happen is when I double-click the...
0
3320
by: Mike Allen | last post by:
Hi Everyone, My problem concerns ContextMenus. It's easy enough to create one and apply it to a NotifyIcon. When it's compiled and run, it works beautifully. Right click and there you are. But I want it to show the ContextMenu on a left click. This seems to be harder than it should be. I've assigned a click event to the NotifyIcon which it...
2
2366
by: Heather R | last post by:
I am writing a windows service that has a notifyicon component. The component displays accordingly, but for some reason, I cannot get the click or double click event to fire. It seems like none of the events are firing for some reason. I have made sure the withevents is in the declaration, but that still doesn't work... Any ideas?? ...
3
8263
by: C Glenn | last post by:
I would like one DoubleClick event handler to handle all double clicks throughout a DataGrid. I've assigned a DoubleClick event handler to the DataGrid and it works nifty-spiffy so long as I click outside the data. The trouble is, the underlying cells or columns or whatever would like to have something to say about this. The cells respond to...
3
7406
by: SteveMac | last post by:
I am using VS2003 VC++ .NET. I want to make a tray icon with a popup menu (like a context menu) that pops up for a left click. I can make the notifyicon with a context menu and that works fine, but I really want it to show the menu for a left click, exactly as it would for a right click. SteveMac
1
4115
by: Marcel Brekelmans | last post by:
Hello, I have implemented a NotiFyIcon and am using both DoubleClick and Click events. But the Doubleclick action on my icon also fires the Click event. Am I missing some setting somewhere or is this normal behavior? I can't find anything about it in the official documentation. Thanks
1
4284
by: \Ji Zhou [MSFT]\ | last post by:
Hello Jason, Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou and I will be working on this issue with you. I have tried to but cannot reproduce your issue on my side. From your codes, I think the logical is, every time the Timer's elapsed event fires, we call the Check_For_Version_Update() function. From the...
0
7781
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7699
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8027
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7788
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6421
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5594
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5292
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3733
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1304
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.