Re: [perl-win32-gui] Last Menu Item Clicked?

2000-02-26 Thread David Hiltz

 Not exactly what I was looking for. I am building the menu within my code
 and so there is no _Click subroutine for each menu item. Unless I can build
 subroutines within my code as well, but I don't know how to go about doing
 that.

  I've done that.  Define the code then use eval to set it up:

  foreach $item (@somelist) {
$sub_code=end_code;
  sub MySub_${item}_Click {
  \$SomeFlag = "$item";
  ...
  }
end_code

   eval $sub_code;
  }





RE: [perl-win32-gui] Last Menu Item Clicked?

2000-02-25 Thread Thomas, Timothy B

Not exactly what I was looking for. I am building the menu within my code
and so there is no _Click subroutine for each menu item. Unless I can build
subroutines within my code as well, but I don't know how to go about doing
that.
I am making a subroutine for all the menu options of this type, kind of like
this:

sub menuclicked_Click
{
$lastclicked=$Menu-Clicked();
print "$lastclicked\n";
}
---
Here's the actual section of the code I am working with, you can see how I
build the menu and call testit_Click, but testit_Click doesn't know which
menu item called it. I need to find the text of the menu item or even which
item in the sequence was clicked, then I can figure it out from there. you
can see in testit_Click the various ways I have tried to determine what
menuitem was selected.

sub testit_Click
{
print "sent:@_\n";
print "Text it click!\n";
print $RightClickMenu-Selected(),"\n";
print $RightClickMenu-Clicked(),"\n";
print $RightClickMenu-Text(),"\n";
print "\n$windowtext\n";
}

sub TrayIcon_RightClick
{

my @tempmenu=(
"$title Options" = "POPUP_TrayIcon",
"   Open" = "TrayIconOpen",
"   Close"= "TrayIconClose",
"-"= 0,
);

Win32::Setupsup::EnumWindows(\@windows);
foreach $window (@windows)
{
Win32::Setupsup::GetWindowText($window, \$windowtext);
if ((GUI::IsEnabled($window)) and (!GUI::IsVisible($window))
and (GUI::IsIconic($window)) and ($windowtext))
{@tempmenu=(@tempmenu,"   $windowtext"
= "testit",);}
}

$RightClickMenu = Win32::GUI::MakeMenu(@tempmenu);

my($X, $Y) = Win32::GUI::GetCursorPos();
$Window-TrackPopupMenu($RightClickMenu -{POPUP_TrayIcon}, $X, $Y);
Refresh_Click();
return 1;
}



-
Tim Thomas
Unix Systems Administrator
Lockheed Martin EIS · Denver Data Center
303-430-2281 · Pager 800-545-3704
mailto:[EMAIL PROTECTED]
Pager: mailto:[EMAIL PROTECTED]

-

 -Original Message-
 From: Eric C. Hansen [SMTP:[EMAIL PROTECTED]]
 Sent: Friday, February 25, 2000 11:43 AM
 To:   [EMAIL PROTECTED]
 Subject:  RE: [perl-win32-gui] Last Menu Item Clicked?
 
 Sure.  Just declare a global variable such as $last_clicked.  Then, in the
 click event for each menu option, set the $last_clicked variable to some
 value that lets you identify that menu item.
 
 # Example Source
 .
 .
 .
 $last_clicked="";
 Win32::GUI::Dialog();
 
 
 sub Open_Click {
$last_clicked="Open";
 }
 
 sub Browse_Click {
$last_clicked="Browse";
 }
 
 Regards,
 Eric
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]On Behalf Of Thomas, Timothy B
 Sent: Friday, February 25, 2000 12:19 PM
 To: '[EMAIL PROTECTED]'
 Subject: [perl-win32-gui] Last Menu Item Clicked?
 
 
 Is there any way to determine after the fact which Menu item was clicked
 last?
 Maybe something like?
   print $Menu-Clicked(),"\n";
 
 
 --
 --
 -
 Tim Thomas
 Unix Systems Administrator
 Lockheed Martin EIS · Denver Data Center
 303-430-2281 · Pager 800-545-3704
 mailto:[EMAIL PROTECTED]
 Pager: mailto:[EMAIL PROTECTED]
 --
 --
 -