Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActivePerl: Possible to create notification bubbles?

Status
Not open for further replies.

bene223

Programmer
Aug 18, 2003
2
US
I am creating a log monitor in Perl on Windows XP and was wondering if it is possible to create notification bubble. For example, my program's icon will be in the system tray and should the log file change, a notification bubble will pop up from the program's system tray icon saying the log has changed.
 
Thats a pretty esoteric question for a perl forum. If you get no replies here try perlmonks.com or stackoverflow.com

Personally I assume its possible but have no idea how its done.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
A free way of doing what PerlTray does is to use Win32::GUI. I know for sure there's a way to put an icon in the notification area (system tray) which can respond to various kinds of clicks by popping up a menu, as I've done this before (to create a systray icon for my otherwise Tk-based GUIs).

I haven't done any balloon popups with Win32::GUI though but I bet it's possible; it'll just take a bit of digging.

Browse the distribution to see what sample scripts come with it.

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Here:
This is one of the demo scripts that comes with Win32::GUI. If you run the command `ppm install Win32::GUI` in the command prompt, this demo will be located at C:\Perl\site\lib\Win32\GUI\demos (assuming you installed Perl in C:\Perl).

It creates a window where you can show/hide a notification icon and do a bunch of things to it, including popping up a notification balloon.

Relevant bits of code:

Code:
		$cfg{ni} = $win->AddNotifyIcon(
			-icon            => $cfg{icon},
			-tip             => $win->TTF->Text(),
			-balloon         => 0,
			-balloon_tip     => $win->BTF2->Text(),
			-balloon_title   => $win->BTF1->Text(),
			-balloon_timeout => $win->BTF3->Text(),
			-balloon_icon    => $win->BCB->Text(),
		);

[...]

$mw->AddButton(
	-name    => "BB1",
	-text    => "Show Balloon",
	-left    => $col2_ctrl_right - 81,
	-top     => $row4_gb_bottom - $margin - 4 - (2 * 21),
	-width   => 81,
	-height  => 21,
	-onClick => sub { $cfg{ni}->ShowBalloon(0),$cfg{ni}->ShowBalloon(1) if $cfg{ni}; 1;},
	-tabstop => 1,
	-group   => 1,
);

Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top