Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 :)

Posted

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

  • Administrators
Posted

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

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted (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 by cattivik66

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...