Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #148339

time out on windows pop up

From T <T@invalid.invalid>
Newsgroups comp.lang.c
Subject time out on windows pop up
Date 2019-12-02 02:42 -0800
Organization A noiseless patient Spider
Message-ID <qs2pre$5b5$1@dont-email.me> (permalink)

Show all headers | View raw


Hi All,

I write in Perl6.  I wrote a module to give me a pop up
in Windows to send information to the user.  It uses
a native call to C.

Do any of you guys know how to add a time out to the
pop up?  I do believe it would be in the choice of the
constants.

Many thanks,
-T


<WinMsg.pm6>
# unit module WinMsg;
# WinMsg.pm6

#`{
       Reference:
 
https://stackoverflow.com/questions/59105696/how-can-i-create-pop-up-windows-for-perl6-in-windows
}

use NativeCall;

sub WinMsg( Str $TitleStr, Str $MessageStr ) is export( :WinMsg ) {
#`{

     Pop up a message box to the user.  Windows only.
     Test one liner:
        perl6 -e "use lib '.'; use WinMsg :WinMsg; WinMsg( 'Super Duper 
Title', 'What? You were expecting something witty?' );"

}

    my $SubName = &?ROUTINE.name;
    my $OS      = $*KERNEL.name;
    if not $OS eq "win32" { say "Sorry, $SubName only work in Windows."; 
exit; }

    constant WCHAR              = uint16;
    constant INT                = int32;
    constant UINT               = uint32;
    constant HANDLE             = Pointer[void];
    constant LPWCTSTR           = CArray[WCHAR];
    constant MB_ICONEXCLAMATION = 0x00000030;

    # Note: the following two subs have to be embedded

    sub MessageBoxW( HANDLE, LPWCTSTR, LPWCTSTR, UINT ) is 
native('user32') returns INT { * };

    sub to-c-str( Str $str ) returns CArray[WCHAR]  {
       my @str := CArray[WCHAR].new;
       for ( $str.comb ).kv -> $i, $char { @str[$i] = $char.ord; }
       @str[ $str.chars ] = 0;
       @str;
    }

    # MessageBoxW( my $handle, to-c-str("๘❤ Raku is awesome ❤๖"), 
to-c-str("Hellö Wαrld"), MB_ICONEXCLAMATION );

    MessageBoxW( my $handle, to-c-str( $MessageStr ), to-c-str( 
$TitleStr ), MB_ICONEXCLAMATION );
}
</WinSmg/pm6>

Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

time out on windows pop up T <T@invalid.invalid> - 2019-12-02 02:42 -0800
  Re: time out on windows pop up gazelle@shell.xmission.com (Kenny McCormack) - 2019-12-02 11:19 +0000
    Re: time out on windows pop up chad <cdalten@gmail.com> - 2019-12-02 05:44 -0800
      Re: time out on windows pop up "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2019-12-02 17:10 -0800
    Re: time out on windows pop up Lynn McGuire <lynnmcguire5@gmail.com> - 2019-12-02 14:01 -0600
      Re: time out on windows pop up gazelle@shell.xmission.com (Kenny McCormack) - 2019-12-02 20:03 +0000
      Re: time out on windows pop up hans.wurst@invalid.invalid - 2019-12-02 21:27 +0100
        Re: time out on windows pop up chad <cdalten@gmail.com> - 2019-12-02 12:51 -0800
          Re: time out on windows pop up "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2019-12-02 20:41 -0800
          Re: time out on windows pop up hans.wurst@invalid.invalid - 2019-12-03 07:38 +0100
            Re: time out on windows pop up chad <cdalten@gmail.com> - 2019-12-03 05:05 -0800
      Re: time out on windows pop up T <T@invalid.invalid> - 2019-12-02 21:03 -0800
        Re: time out on windows pop up Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-12-03 18:50 +0000
          Re: time out on windows pop up T <T@invalid.invalid> - 2019-12-03 14:19 -0800
            Re: time out on windows pop up T <T@invalid.invalid> - 2019-12-03 14:19 -0800
            Re: time out on windows pop up Bart <bc@freeuk.com> - 2019-12-04 12:25 +0000
              Re: time out on windows pop up Bart <bc@freeuk.com> - 2019-12-04 15:33 +0000
                Re: time out on windows pop up T <T@invalid.invalid> - 2019-12-04 10:18 -0800
                Re: time out on windows pop up chad <cdalten@gmail.com> - 2019-12-05 06:28 -0800

csiph-web