cattivik66 Posted April 4, 2004 Posted April 4, 2004 Hi all! I've added a NotifyIcon to my Console application. It works but.. the raise event's of NotifyIcon doesnt' works! Added references to: System.Windows.Forms System.Drawing Imports System.Drawing Imports System.Windows.Forms Module Module1 Dim NotifyIcon As System.Windows.Forms.NotifyIcon Private mSmileIcon As New System.Drawing.Icon("D:\face02.ico") Public Sub Main() NotifyIcon = New System.Windows.Forms.NotifyIcon NotifyIcon.Icon = mSmileIcon NotifyIcon.Text = "Right Click for the menu" NotifyIcon.Visible = True End Sub Private Sub NotifyIcon_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon.MouseMove Console.WriteLine("MOUSEMOVE") End Sub End Module NotifyIcon_MouseMove doesn't raise :( some1 know why? thanks in advantage :) Quote
cattivik66 Posted April 5, 2004 Author Posted April 5, 2004 i've found the problem (but not the solution! :( )! While Trim$(LCase$(strCommand)) <> "quit" Console.WriteLine() 'Read the command strCommand = Console.ReadLine() Select Case strCommand 'code.. end select Wend if i move the mouse on the icon and then press enter.. the program go into the select and the event is raised Quote
Administrators PlausiblyDamp Posted April 5, 2004 Administrators Posted April 5, 2004 The problem is it is waiting for the readline to return before it can process any further commands. Not sure if there is a better way but I've just hacked a quick fix together.... Sub Main() Dim ni As New System.Windows.Forms.NotifyIcon ni.Icon = New System.Drawing.Icon("..\Face01.ico") ni.Visible = True AddHandler ni.Click, AddressOf Clicked System.Windows.Forms.Application.Run() End Sub Private Sub Clicked(ByVal sender As Object, ByVal e As EventArgs) Console.WriteLine("Click") End Sub Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cattivik66 Posted April 5, 2004 Author Posted April 5, 2004 (edited) Yeah! Great code thx ;) Only a little problem.. after System.Windows.Forms.Application.Run() the application seems to stop.. cannot write in the console :/ and the code i Wrote to hide the console doesn't work more :/ I've tried to add a Timer that makes DoEvents() but doesn't work too so.. if i make System.Windows.Forms.Application.Exit() the program continue working but the console go away and using System.Windows.Forms.Application.Run() it doesn't re-appare is possible to make an event for the console so that I read the keys from the console in stream? ;) perhaps so works :p Edited April 5, 2004 by cattivik66 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.