Hi,

I've had a quick play with this, and it seems that you need to use AddNotifyIcon rather than Win32::GUI::NotifyIcon->new - I guess that the NotifyIcon needs to be associated to a window. This may, or may not be a bug:)

The following code does what you want (I think):

Cheers,

jez.
---------------------
use Win32::GUI;
my $Window = new Win32::GUI::Window (
-name   => "Window",
-left   => 300,
-top    => 400,
-width  => 222,
-height => 300,
-text   => "Test",
);

$|=1;
$icon1=new Win32::GUI::Icon("id.ico");
$icon2=new Win32::GUI::Icon("id_high.ico");
$Window->Hide;
$tt=$Window->AddNotifyIcon(-id=>1,-name=>"NI",-tip=>"Test",-icon=>$icon1);
while()
{
Win32::GUI::DoEvents;
 print ".";
 $x++;
 if ($x==5)  { print $tt->Change(-id=>1,-icon=>$icon2); }
 if ($x==10) { print $tt->Change(-id=>1,-icon=>$icon1); $x=0; }
 # Wanna do some real work here ...
 select (undef,undef,undef,0.25);
}

sub NI_Click
{
 print "CLICKED(".join(",",@_).")";
 1;
}

sub NI_MouseEvent
{
 print "MOUSEEVENT(".join(",",@_).")";
 1;
}



----- Original Message ----- From: <[EMAIL PROTECTED]>
To: <perl-win32-gui-users@lists.sourceforge.net>
Sent: Saturday, October 09, 2004 1:04 AM
Subject: [perl-win32-gui-users] Got NotifyIcon but no events :(


Hello there,

i try to use a notifyicon (but nothing else from Win32::GUI). My prog should be able to change the icon and detect mouseclicks. I managed so far, thar an changing icon gets displayed, but failed to create interaction. As soon as i
move the mouse over the icon, it disappears and my program looses the
connection (Change returns 0 instead of 1).
Please give me a hint!

Thanks in advance,
Harry



use Win32::GUI;
$|=1;
$icon1=new Win32::GUI::Icon("id.ico");
$icon2=new Win32::GUI::Icon("id_high.ico");

$tt=new
Win32::GUI::NotifyIcon(undef,-id=>1,-name=>"NI",-tip=>"Test",-icon=>$icon1);

while()
{
 Win32::GUI::DoEvents;
 print ".";
 $x++;
 if ($x==5)  { print $tt->Change(-id=>1,-icon=>$icon2); }
 if ($x==10) { print $tt->Change(-id=>1,-icon=>$icon1); $x=0; }
 # Wanna do some real work here ...
 select (undef,undef,undef,0.25);
}

sub NI_Click
{
 print "CLICKED(".join(",",@_).")";
 1;
}

sub NI_MouseEvent
{
 print "MOUSEEVENT(".join(",",@_).")";
 1;
}




-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users


Reply via email to