RE: Adding a Timer in Win32::GUI

2002-10-08 Thread Krummel, James C - PGGC-6


Eric,

Here is another way to do This:

use Win32::OLE;

$vbOKOnly = 0;
$vbYesNo = 4;
$vbCritical = 16;
$vbWarning = 48;
$vbInformation = 64;
$WSHShell = Win32::OLE->CreateObject('Wscript.Shell');
$Return = $WSHShell->Popup("Windows could not finish a system task and needs
to restart.\n\nNOTE: You MUST reboot  Windows so that this task may
finish.\nReboot Windows now?", 10, "Error", $vbCritical + $vbYesNo);
print $Return;


James Krummel

-Original Message-
From: "Hawley, Eric" <[EMAIL PROTECTED]>
To: "'[EMAIL PROTECTED]'"
<[EMAIL PROTECTED]>
Subject: Adding a Timer in Win32::GUI
Date: Tue, 8 Oct 2002 14:53:02 -0400 

Okay I have been attempting to add a timer to a message box and have been
unsuccessful in being able to do so.  I want to have it so that after the
message box displays the user has 10 seconds to either click YES or NO with
default as YES.  If after 10 seconds the user has failed to make a selection
YES will be automatically choosen. can someone help me out with this. Down
below is some code that I have from the script.


my $choice = GUI::MessageBox(GUI::GetForegroundWindow(), "Windows could not
finish a system task and needs to restart.\n\nNOTE: You MUST reboot Windows
so that this task may finish.\nReboot Windows now?", "Error", MB_YESNO |
MB_ICONINFORMATION | MB_DEFBUTTON1);

$Window->Addtimer( "Timer", 1 ); #Need advice as to how to get the
correct value for $Window


Does anyone know what else I need to add to get this to work?
Thanks for your help

*   Eric Hawley, Network Services Intern
> * Office of Information Technology
> * Ohio Department of Natural Resources
> * Phone:  (614) 265-1028
> * Mailto:[EMAIL PROTECTED]
> 
> 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Adding a Timer in Win32::GUI

2002-10-08 Thread Peter Eisengrein
Title: RE: Adding a Timer in Win32::GUI





Assuming $choice is your message box, perhaps something like this would work?


### untested


sub No_Click
{
    $choice->Hide();
    $Window->Timer->Kill();
    ### do something else
    return 1;
}



sub Timer
{
    if ($choice->IsVisible)
    {
        $choice->Hide();
        $Window->Timer->Kill();
        &Yes();
        return 1;
    }
    else
    {
        return 0;
    }


    
}
        


sub Yes_Click
{
    &Yes();
}


sub Yes
{
    ### Do something... (reboot?)
    return 1;
}






> -Original Message-
> From: Hawley, Eric [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 08, 2002 14:53
> To: '[EMAIL PROTECTED]'
> Subject: Adding a Timer in Win32::GUI
> 
> 
> Okay I have been attempting to add a timer to a message box 
> and have been
> unsuccessful in being able to do so.  I want to have it so 
> that after the
> message box displays the user has 10 seconds to either click 
> YES or NO with
> default as YES.  If after 10 seconds the user has failed to 
> make a selection
> YES will be automatically choosen. can someone help me out 
> with this. Down
> below is some code that I have from the script.
> 
> 
> my $choice = GUI::MessageBox(GUI::GetForegroundWindow(), 
> "Windows could not
> finish a system task and needs to restart.\n\nNOTE: You MUST 
> reboot Windows
> so that this task may finish.\nReboot Windows now?", "Error", 
> MB_YESNO |
> MB_ICONINFORMATION | MB_DEFBUTTON1);
> 
> $Window->Addtimer( "Timer", 1 );   #Need advice as to how 
> to get the
> correct value for $Window
> 
> 
> Does anyone know what else I need to add to get this to work?
> Thanks for your help
> 
> * Eric Hawley, Network Services Intern
> > *   Office of Information Technology
> > *   Ohio Department of Natural Resources
> > *   Phone:  (614) 265-1028
> > *   Mailto:[EMAIL PROTECTED]
> > 
> > 
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 





Re: Adding a Timer in Win32::GUI

2002-10-08 Thread Johan Lindstrom

At 14:53 2002-10-08 -0400, Hawley, Eric wrote:
>Okay I have been attempting to add a timer to a message box and have been
>unsuccessful in being able to do so.  I want to have it so that after the
>message box displays the user has 10 seconds to either click YES or NO with
>default as YES.  If after 10 seconds the user has failed to make a selection
>YES will be automatically choosen. can someone help me out with this. Down
>below is some code that I have from the script.

I would be surprised it that compiled and ran. This does.


#!/usr/bin/perl -w
use strict;
use Win32::GUI;


my $winDummy = Win32::GUI::Window->new(-name => "winApp");  #Create, but 
never Show() it
my $timTimeout = $winDummy->AddTimer( "timTimeout", 1 );#10 sec

my $choise = Win32::GUI::MessageBox($winDummy, q {Windows could not finish 
a system task and needs to restart.

NOTE: You MUST reboot Windows so that this task may finish.
Reboot Windows now?},
 "Error", MB_YESNO | MB_ICONINFORMATION | MB_DEFBUTTON1);

print "choice: ($choise)\n";
shutdownWindows() if($choise == 6); #6 seems to be YES



sub timTimeout_Timer {
 print "Timeout...\n";

 #Disable the timer, otherwise it will trigger this event
 #handler again
 $timTimeout->Kill();

 #Never to return
 shutdownWindows();
}

sub shutdownWindows {
 print "do your Windows reboot stuff here, then exit the app\n";

 #This is the downside. You have to exit the Perl script
 #for the dialog box to disappear (I think, please prove me
 #wrong someone!).
 exit(0);
}


__END__

Interesting note: We never call Win32::GUI::Dialog(), and the timer still 
works.

An alternative would be to create the dialog box yourself. That way it's 
like any Win32::GUI::Window, and you can close it the normal way. That's 
what I'd do, but if this brute force solution works for you...


/J

 --  --- -- --  --  -- -  - -
Johan LindströmSourcerer @ Boss Casinos [EMAIL PROTECTED]

Latest bookmark: "SQLite An Embeddable SQL Database Engine"
http://www.hwaci.com/sw/sqlite/
dmoz (1 of 6): ...puters/Software/Configuration_Management/Tools/ 26


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Adding a Timer in Win32::GUI

2002-10-08 Thread Hawley, Eric

Okay I have been attempting to add a timer to a message box and have been
unsuccessful in being able to do so.  I want to have it so that after the
message box displays the user has 10 seconds to either click YES or NO with
default as YES.  If after 10 seconds the user has failed to make a selection
YES will be automatically choosen. can someone help me out with this. Down
below is some code that I have from the script.


my $choice = GUI::MessageBox(GUI::GetForegroundWindow(), "Windows could not
finish a system task and needs to restart.\n\nNOTE: You MUST reboot Windows
so that this task may finish.\nReboot Windows now?", "Error", MB_YESNO |
MB_ICONINFORMATION | MB_DEFBUTTON1);

$Window->Addtimer( "Timer", 1 ); #Need advice as to how to get the
correct value for $Window


Does anyone know what else I need to add to get this to work?
Thanks for your help

*   Eric Hawley, Network Services Intern
> * Office of Information Technology
> * Ohio Department of Natural Resources
> * Phone:  (614) 265-1028
> * Mailto:[EMAIL PROTECTED]
> 
> 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs