For example,
#!perl # # [id://11122933] use 5.012; # strict, // use warnings; use Win32::SysTray; use Win32 qw/MB_ICONEXCLAMATION MB_ICONSTOP MB_ICONQUESTION MB_ICONINF +ORMATION/; $| = 1; my $tray = new Win32::SysTray ( 'icon' => 'C:\images\logo.ico', 'single' => 1, ) or exit 0; # each row of @choices needs a hashref, with the keys name, text, and +action -- name should be a perl-safe-identifier (single word), text i +s visible string, and action is a coderef my @choices = ( { name => 'EmployeeManagement', text => 'Employee Management', act +ion => sub { Win32::MsgBox("Do some management task", 0 | MB_ICONINFO +RMATION, 'Employee Management')} }, { name => 'Quit', text => 'Quit', action => sub { print "Exiting p +er user request\n"; exit 0 } }, ); my $DIALOG = create_dialog(); $tray->setMenu ( "> Show &Dialog" => sub { $DIALOG->Show() }, # can re-show +the dialog, too ">-" => 0, "> E&xit" => sub { return -1 }, ); $DIALOG->Show(); # if you want this dialog to default to visible; o +therwise, remove this line and rely on the tray to start it Win32::GUI::Dialog(); exit; sub create_dialog { my $dlg = Win32::GUI::DialogBox->new( -name => 'DlgBox', -text => 'Option Menu', -width => 300, -height => 120 + 20*@choices, ); $dlg->AddLabel( -text => 'Please make a selection', -pos => [15,10], -size => [$dlg->ScaleWidth() - 30 , 30], ); $dlg->AddButton( -text => 'Ok', -default => 1, -ok => 1, -size => [60,20], -pos => [$dlg->ScaleWidth() - 140, $dlg->ScaleHeight - 30], -onClick => \&DlgBox_Process, ); $dlg->AddButton( -text => 'Cancel', -cancel => 1, -size => [60,20], -pos => [$dlg->ScaleWidth() - 70, $dlg->ScaleHeight - 30], -onClick => \&DlgBox_Terminate, ); my $top = 50; for my $opt ( @choices ) { $dlg->AddRadioButton( -name => $opt->{name}, -size => [15,15], -pos => [15, $top], ); $dlg->AddLabel( -text => $opt->{text}, -pos => [45, $top], -size => [$dlg->ScaleWidth() - 45 - 10,15], ); $top += 20; } return $dlg; } sub DlgBox_Process { my $action = undef; for my $opt ( @choices ) { if( $DIALOG->{$opt->{name}}->Checked()) { $action = $opt->{action}; last; } } if(defined $action) { $DIALOG->Hide(); $action->(); #$DIALOG->Show(); # un-comment to automatically re-show the ma +in input dialog } else { Win32::MsgBox("Programmer needs to define action!", 0 | MB_ICO +NEXCLAMATION, 'ERROR in Management Dialog!') } return 0; } sub DlgBox_Terminate { $DIALOG->Hide(); return 0; }

In reply to Re^2: Win32::SysTray Issue by pryrt
in thread Win32::SysTray Issue by PilotinControl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.