My pop ups for windows module

Hi All,

I wrote and extensive module for pop up in Windows.

It does not contain a time out option.  Maybe some day I
will work on the timer function.

Thank you all for helping me with various parts of this!

There are basically two subs to import
     WinMsg  and  WinPopUp

Here are some one liners to test it with:

perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp( 'Super 
Duper Title', 'What? You were expecting something witty?', 
'Information', 'Ok'  );"

perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp( 'Super 
Duper Title', 'What? You were expecting something witty?', 'Question', 
'YesNoCancel' );

perl6 -e "use lib '.'; use WinPopUps :WinPopUp, :WinMsg; WinMsg( 'Super 
Duper Title', 'What? You were expecting something witty?' );"

Let me know if you find any booboo's.

-T


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

#`{
       Reference:
 
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox
 
https://stackoverflow.com/questions/59105696/how-can-i-create-pop-up-windows-for-perl6-in-windows
}

use NativeCall;

sub WinPopUp( Str $TitleStr,
               Str $MessageStr,
               Str $Icons where   * ~~ "Exclamation"             |
                                       "Warning"                 |
                                       "Information"             |
                                       "Asterisk"                |
                                       "Question"                |
                                       "Stop"                    |
                                       "Error"                   |
                                       "Hand",
               Str $Buttons where * ~~ "AbortRetryIgnore"        |
                                       "CancelTryAgainContinue"  |
                                       "Help"                    |
                                       "Ok"                      |
                                       "OkCancel"                |
                                       "RetryCancel"             |
                                       "YesNo"                   |
                                       "YesNoCancel" )
               is export( :WinPopUp ) {

#`{

     Pop up a message box to the user.  Windows only.
     Return what button was pressed

     Note: you are constrainedthe the Icon and Button values shown in 
the sub declaration.

     Test one liners:
         perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp( 
'Super Duper Title', 'What? You were expecting something witty?', 
'Information', 'Ok'  );"
         perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp( 
'Super Duper Title', 'What? You were expecting something witty?', 
'Question', 'YesNoCancel' );

}

    my Str $SubName = &?ROUTINE.name;
    my Str $OS      = $*KERNEL.name;

    if not $OS eq "win32" { say "Sorry, $SubName only work in Windows."; 
exit; }
    my int32 $RtnInt = 0;
    my Str   $RtnStr = "";
    my int32 $IconInt;
    my int32 $ButtonInt;
    my int32 $UINT;

    # Note: these constants are 32 bit
    constant WCHAR              = uint16;
    constant INT                = int32;
    constant UINT               = uint32;
    constant HANDLE             = Pointer[void];
    constant LPWCTSTR           = CArray[WCHAR];


    constant MB_ICONEXCLAMATION   = 0x00000030;
    constant MB_ICONWARNING       = 0x00000030;
    constant MB_ICONINFORMATION   = 0x00000040;
    constant MB_ICONASTERISK      = 0x00000040;
    constant MB_ICONQUESTION      = 0x00000020;
    constant MB_ICONSTOP          = 0x00000010;
    constant MB_ICONERROR         = 0x00000010;
    constant MB_ICONHAND          = 0x00000010;


    constant MB_ABORTRETRYIGNORE  = 0x00000002;
    constant MB_CANCELTRYCONTINUE = 0x00000006;
    constant MB_HELP              = 0x00004000;
    constant MB_OK                = 0x00000000;
    constant MB_OKCANCEL          = 0x00000001;
    constant MB_RETRYCANCEL       = 0x00000005;
    constant MB_YESNO             = 0x00000004;
    constant MB_YESNOCANCEL       = 0x00000003;

    constant DABORT     =  3;
    constant IDCANCEL   =  2;
    constant IDCONTINUE = 11;
    constant IDIGNORE   =  5;
    constant IDNO       =  7;
    constant IDOK       =  1;
    constant IDRETRY    =  4;
    constant IDTRYAGAIN = 10;
    constant IDYES      =  6;


    # 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;
    }


    if     $Icons eq "Exclamation"  { $IconInt = MB_ICONEXCLAMATION; }
    elsif  $Icons eq "Warning"      { $IconInt = MB_ICONWARNING; }
    elsif  $Icons eq "Information"  { $IconInt = MB_ICONINFORMATION; }
    elsif  $Icons eq "Asterisk"     { $IconInt = MB_ICONASTERISK; }
    elsif  $Icons eq "Question"     { $IconInt = MB_ICONQUESTION; }
    elsif  $Icons eq "Stop"         { $IconInt = MB_ICONSTOP; }
    elsif  $Icons eq "Error"        { $IconInt = MB_ICONERROR; }
    elsif  $Icons eq "Hand"         { $IconInt = MB_ICONHAND; }

    if     $Buttons eq "AbortRetryIgnore"       { $ButtonInt = 
MB_ABORTRETRYIGNORE; }
    elsif  $Buttons eq "CancelTryAgainContinue" { $ButtonInt = 
MB_CANCELTRYCONTINUE; }
    elsif  $Buttons eq "Help"                   { $ButtonInt = MB_HELP; }
    elsif  $Buttons eq "Ok"                     { $ButtonInt = MB_OK; }
    elsif  $Buttons eq "OkCancel"               { $ButtonInt = 
MB_OKCANCEL; }
    elsif  $Buttons eq "RetryCancel"            { $ButtonInt = 
MB_RETRYCANCEL; }
    elsif  $Buttons eq "YesNo"                  { $ButtonInt = MB_YESNO; }
    elsif  $Buttons eq "YesNoCancel"            { $ButtonInt = 
MB_YESNOCANCEL; }

    $UINT = $IconInt +| $ButtonInt;   # Bitwise OR them together

    $RtnInt = MessageBoxW( my $handle, to-c-str( $MessageStr ), 
to-c-str( $TitleStr ), $UINT );

    # say $RtnInt;
    if     $RtnInt == DABORT      { $RtnStr = "Abort"; }
    elsif  $RtnInt == IDCANCEL    { $RtnStr = "Cancel"; }
    elsif  $RtnInt == IDCONTINUE  { $RtnStr = "Continue"; }
    elsif  $RtnInt == IDIGNORE    { $RtnStr = "Ignore"; }
    elsif  $RtnInt == IDNO        { $RtnStr = "No"; }
    elsif  $RtnInt == IDOK        { $RtnStr = "Ok"; }
    elsif  $RtnInt == IDRETRY     { $RtnStr = "Retry"; }
    elsif  $RtnInt == IDTRYAGAIN  { $RtnStr = "Try Again"; }
    elsif  $RtnInt == IDYES       { $RtnStr = "Yes"; }

    return $RtnStr;
}


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

#`{
      Simple "Ok" pop up with no return value

      Test one liner:
          perl6 -e "use lib '.'; use WinPopUps :WinPopUp, :WinMsg; 
WinMsg( 'Super Duper Title', 'What? You were expecting something witty?' );"

}

    WinPopUp( $TitleStr, $MessageStr, "Information", "Ok" );

}
</WinpopUps.pm6>
0
perl6
12/7/2019 11:39:45 AM
perl.perl6.users 1389 articles. 0 followers. Follow

5 Replies
64 Views

Similar Articles

[PageSpeed] 9

--0000000000004575ca05991c3d4e
Content-Type: text/plain; charset="UTF-8"

On Sat, Dec 7, 2019 at 05:41 ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> Hi All,
>
> I wrote and extensive module for pop up in Windows.


Todd, you need to publish your module to the Raku module ecosystem. Many
people, including myself, want to see an easily-installable module with at
least some basic tests to give strangers confidence that it will not blow
up. Instructions are in the docs, and there are helper modules to get you
started.

I'll send you specific doc references later when I get a chance, but it's
probably better for you to dig around the doc site a bit more on your own.
Hint: in the search box, enter 'module'.

-Tom


>
> It does not contain a time out option.  Maybe some day I
> will work on the timer function.
>
> Thank you all for helping me with various parts of this!
>
> There are basically two subs to import
>      WinMsg  and  WinPopUp
>
> Here are some one liners to test it with:
>
> perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp( 'Super
> Duper Title', 'What? You were expecting something witty?',
> 'Information', 'Ok'  );"
>
> perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp( 'Super
> Duper Title', 'What? You were expecting something witty?', 'Question',
> 'YesNoCancel' );
>
> perl6 -e "use lib '.'; use WinPopUps :WinPopUp, :WinMsg; WinMsg( 'Super
> Duper Title', 'What? You were expecting something witty?' );"
>
> Let me know if you find any booboo's.
>
> -T
>
>
> <WinPopUps.pm6>
> # unit module WinPopUps;
> # WinMsg.pm6
>
> #`{
>        Reference:
>
>
> https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox
>
>
> https://stackoverflow.com/questions/59105696/how-can-i-create-pop-up-windows-for-perl6-in-windows
> }
>
> use NativeCall;
>
> sub WinPopUp( Str $TitleStr,
>                Str $MessageStr,
>                Str $Icons where   * ~~ "Exclamation"             |
>                                        "Warning"                 |
>                                        "Information"             |
>                                        "Asterisk"                |
>                                        "Question"                |
>                                        "Stop"                    |
>                                        "Error"                   |
>                                        "Hand",
>                Str $Buttons where * ~~ "AbortRetryIgnore"        |
>                                        "CancelTryAgainContinue"  |
>                                        "Help"                    |
>                                        "Ok"                      |
>                                        "OkCancel"                |
>                                        "RetryCancel"             |
>                                        "YesNo"                   |
>                                        "YesNoCancel" )
>                is export( :WinPopUp ) {
>
> #`{
>
>      Pop up a message box to the user.  Windows only.
>      Return what button was pressed
>
>      Note: you are constrainedthe the Icon and Button values shown in
> the sub declaration.
>
>      Test one liners:
>          perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp(
> 'Super Duper Title', 'What? You were expecting something witty?',
> 'Information', 'Ok'  );"
>          perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp(
> 'Super Duper Title', 'What? You were expecting something witty?',
> 'Question', 'YesNoCancel' );
>
> }
>
>     my Str $SubName = &?ROUTINE.name;
>     my Str $OS      = $*KERNEL.name;
>
>     if not $OS eq "win32" { say "Sorry, $SubName only work in Windows.";
> exit; }
>     my int32 $RtnInt = 0;
>     my Str   $RtnStr = "";
>     my int32 $IconInt;
>     my int32 $ButtonInt;
>     my int32 $UINT;
>
>     # Note: these constants are 32 bit
>     constant WCHAR              = uint16;
>     constant INT                = int32;
>     constant UINT               = uint32;
>     constant HANDLE             = Pointer[void];
>     constant LPWCTSTR           = CArray[WCHAR];
>
>
>     constant MB_ICONEXCLAMATION   = 0x00000030;
>     constant MB_ICONWARNING       = 0x00000030;
>     constant MB_ICONINFORMATION   = 0x00000040;
>     constant MB_ICONASTERISK      = 0x00000040;
>     constant MB_ICONQUESTION      = 0x00000020;
>     constant MB_ICONSTOP          = 0x00000010;
>     constant MB_ICONERROR         = 0x00000010;
>     constant MB_ICONHAND          = 0x00000010;
>
>
>     constant MB_ABORTRETRYIGNORE  = 0x00000002;
>     constant MB_CANCELTRYCONTINUE = 0x00000006;
>     constant MB_HELP              = 0x00004000;
>     constant MB_OK                = 0x00000000;
>     constant MB_OKCANCEL          = 0x00000001;
>     constant MB_RETRYCANCEL       = 0x00000005;
>     constant MB_YESNO             = 0x00000004;
>     constant MB_YESNOCANCEL       = 0x00000003;
>
>     constant DABORT     =  3;
>     constant IDCANCEL   =  2;
>     constant IDCONTINUE = 11;
>     constant IDIGNORE   =  5;
>     constant IDNO       =  7;
>     constant IDOK       =  1;
>     constant IDRETRY    =  4;
>     constant IDTRYAGAIN = 10;
>     constant IDYES      =  6;
>
>
>     # 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;
>     }
>
>
>     if     $Icons eq "Exclamation"  { $IconInt = MB_ICONEXCLAMATION; }
>     elsif  $Icons eq "Warning"      { $IconInt = MB_ICONWARNING; }
>     elsif  $Icons eq "Information"  { $IconInt = MB_ICONINFORMATION; }
>     elsif  $Icons eq "Asterisk"     { $IconInt = MB_ICONASTERISK; }
>     elsif  $Icons eq "Question"     { $IconInt = MB_ICONQUESTION; }
>     elsif  $Icons eq "Stop"         { $IconInt = MB_ICONSTOP; }
>     elsif  $Icons eq "Error"        { $IconInt = MB_ICONERROR; }
>     elsif  $Icons eq "Hand"         { $IconInt = MB_ICONHAND; }
>
>     if     $Buttons eq "AbortRetryIgnore"       { $ButtonInt =
> MB_ABORTRETRYIGNORE; }
>     elsif  $Buttons eq "CancelTryAgainContinue" { $ButtonInt =
> MB_CANCELTRYCONTINUE; }
>     elsif  $Buttons eq "Help"                   { $ButtonInt = MB_HELP; }
>     elsif  $Buttons eq "Ok"                     { $ButtonInt = MB_OK; }
>     elsif  $Buttons eq "OkCancel"               { $ButtonInt =
> MB_OKCANCEL; }
>     elsif  $Buttons eq "RetryCancel"            { $ButtonInt =
> MB_RETRYCANCEL; }
>     elsif  $Buttons eq "YesNo"                  { $ButtonInt = MB_YESNO; }
>     elsif  $Buttons eq "YesNoCancel"            { $ButtonInt =
> MB_YESNOCANCEL; }
>
>     $UINT = $IconInt +| $ButtonInt;   # Bitwise OR them together
>
>     $RtnInt = MessageBoxW( my $handle, to-c-str( $MessageStr ),
> to-c-str( $TitleStr ), $UINT );
>
>     # say $RtnInt;
>     if     $RtnInt == DABORT      { $RtnStr = "Abort"; }
>     elsif  $RtnInt == IDCANCEL    { $RtnStr = "Cancel"; }
>     elsif  $RtnInt == IDCONTINUE  { $RtnStr = "Continue"; }
>     elsif  $RtnInt == IDIGNORE    { $RtnStr = "Ignore"; }
>     elsif  $RtnInt == IDNO        { $RtnStr = "No"; }
>     elsif  $RtnInt == IDOK        { $RtnStr = "Ok"; }
>     elsif  $RtnInt == IDRETRY     { $RtnStr = "Retry"; }
>     elsif  $RtnInt == IDTRYAGAIN  { $RtnStr = "Try Again"; }
>     elsif  $RtnInt == IDYES       { $RtnStr = "Yes"; }
>
>     return $RtnStr;
> }
>
>
> sub WinMsg( Str $TitleStr, Str $MessageStr ) is export( :WinMsg )  {
>
> #`{
>       Simple "Ok" pop up with no return value
>
>       Test one liner:
>           perl6 -e "use lib '.'; use WinPopUps :WinPopUp, :WinMsg;
> WinMsg( 'Super Duper Title', 'What? You were expecting something witty?'
> );"
>
> }
>
>     WinPopUp( $TitleStr, $MessageStr, "Information", "Ok" );
>
> }
> </WinpopUps.pm6>
>

--0000000000004575ca05991c3d4e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div>On Sat, Dec 7, 2019 at 05:41 ToddAndMargo via perl6-users &lt;<a href=
=3D"mailto:perl6-users@perl.org">perl6-users@perl.org</a>&gt; wrote:<br></d=
iv><div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi All,<=
br>
<br>
I wrote and extensive module for pop up in Windows.</blockquote><div dir=3D=
"auto"><br></div><div dir=3D"auto">Todd, you need to publish your module to=
 the Raku module ecosystem. Many people, including myself, want to see an e=
asily-installable module with at least some basic tests to give strangers c=
onfidence that it will not blow up. Instructions are in the docs, and there=
 are helper modules to get you started.</div><div dir=3D"auto"><br></div><d=
iv dir=3D"auto">I&#39;ll send you specific doc references later when I get =
a chance, but it&#39;s probably better for you to dig around the doc site a=
 bit more on your own. Hint: in the search box, enter &#39;module&#39;.</di=
v><div dir=3D"auto"><br></div><div dir=3D"auto">-Tom</div><div dir=3D"auto"=
><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><br>
<br>
It does not contain a time out option.=C2=A0 Maybe some day I<br>
will work on the timer function.<br>
<br>
Thank you all for helping me with various parts of this!<br>
<br>
There are basically two subs to import<br>
=C2=A0 =C2=A0 =C2=A0WinMsg=C2=A0 and=C2=A0 WinPopUp<br>
<br>
Here are some one liners to test it with:<br>
<br>
perl6 -e &quot;use lib &#39;.&#39;; use WinPopUps :WinPopUp; say WinPopUp( =
&#39;Super <br>
Duper Title&#39;, &#39;What? You were expecting something witty?&#39;, <br>
&#39;Information&#39;, &#39;Ok&#39;=C2=A0 );&quot;<br>
<br>
perl6 -e &quot;use lib &#39;.&#39;; use WinPopUps :WinPopUp; say WinPopUp( =
&#39;Super <br>
Duper Title&#39;, &#39;What? You were expecting something witty?&#39;, &#39=
;Question&#39;, <br>
&#39;YesNoCancel&#39; );<br>
<br>
perl6 -e &quot;use lib &#39;.&#39;; use WinPopUps :WinPopUp, :WinMsg; WinMs=
g( &#39;Super <br>
Duper Title&#39;, &#39;What? You were expecting something witty?&#39; );&qu=
ot;<br>
<br>
Let me know if you find any booboo&#39;s.<br>
<br>
-T<br>
<br>
<br>
&lt;WinPopUps.pm6&gt;<br>
# unit module WinPopUps;<br>
# WinMsg.pm6<br>
<br>
#`{<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0Reference:<br>
<br>
<a href=3D"https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-wi=
nuser-messagebox" rel=3D"noreferrer" target=3D"_blank">https://docs.microso=
ft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox</a><br>
<br>
<a href=3D"https://stackoverflow.com/questions/59105696/how-can-i-create-po=
p-up-windows-for-perl6-in-windows" rel=3D"noreferrer" target=3D"_blank">htt=
ps://stackoverflow.com/questions/59105696/how-can-i-create-pop-up-windows-f=
or-perl6-in-windows</a><br>
}<br>
<br>
use NativeCall;<br>
<br>
sub WinPopUp( Str $TitleStr,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Str $MessageStr,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Str $Icons where=C2=
=A0 =C2=A0* ~~ &quot;Exclamation&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0|<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;War=
ning&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|<b=
r>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Inf=
ormation&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Ast=
erisk&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Que=
stion&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Sto=
p&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Err=
or&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0|<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Han=
d&quot;,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Str $Buttons where *=
 ~~ &quot;AbortRetryIgnore&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Can=
celTryAgainContinue&quot;=C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Hel=
p&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Ok&=
quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;OkC=
ancel&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Ret=
ryCancel&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Yes=
No&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0|<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Yes=
NoCancel&quot; )<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0is export( :WinPopUp=
 ) {<br>
<br>
#`{<br>
<br>
=C2=A0 =C2=A0 =C2=A0Pop up a message box to the user.=C2=A0 Windows only.<b=
r>
=C2=A0 =C2=A0 =C2=A0Return what button was pressed<br>
<br>
=C2=A0 =C2=A0 =C2=A0Note: you are constrainedthe the Icon and Button values=
 shown in <br>
the sub declaration.<br>
<br>
=C2=A0 =C2=A0 =C2=A0Test one liners:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0perl6 -e &quot;use lib &#39;.&#39;; use W=
inPopUps :WinPopUp; say WinPopUp( <br>
&#39;Super Duper Title&#39;, &#39;What? You were expecting something witty?=
&#39;, <br>
&#39;Information&#39;, &#39;Ok&#39;=C2=A0 );&quot;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0perl6 -e &quot;use lib &#39;.&#39;; use W=
inPopUps :WinPopUp; say WinPopUp( <br>
&#39;Super Duper Title&#39;, &#39;What? You were expecting something witty?=
&#39;, <br>
&#39;Question&#39;, &#39;YesNoCancel&#39; );<br>
<br>
}<br>
<br>
=C2=A0 =C2=A0 my Str $SubName =3D &amp;?ROUTINE.name;<br>
=C2=A0 =C2=A0 my Str $OS=C2=A0 =C2=A0 =C2=A0 =3D $*KERNEL.name;<br>
<br>
=C2=A0 =C2=A0 if not $OS eq &quot;win32&quot; { say &quot;Sorry, $SubName o=
nly work in Windows.&quot;; <br>
exit; }<br>
=C2=A0 =C2=A0 my int32 $RtnInt =3D 0;<br>
=C2=A0 =C2=A0 my Str=C2=A0 =C2=A0$RtnStr =3D &quot;&quot;;<br>
=C2=A0 =C2=A0 my int32 $IconInt;<br>
=C2=A0 =C2=A0 my int32 $ButtonInt;<br>
=C2=A0 =C2=A0 my int32 $UINT;<br>
<br>
=C2=A0 =C2=A0 # Note: these constants are 32 bit<br>
=C2=A0 =C2=A0 constant WCHAR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =3D uint16;<br>
=C2=A0 =C2=A0 constant INT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =3D int32;<br>
=C2=A0 =C2=A0 constant UINT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0=3D uint32;<br>
=C2=A0 =C2=A0 constant HANDLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0=3D Pointer[void];<br>
=C2=A0 =C2=A0 constant LPWCTSTR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D=
 CArray[WCHAR];<br>
<br>
<br>
=C2=A0 =C2=A0 constant MB_ICONEXCLAMATION=C2=A0 =C2=A0=3D 0x00000030;<br>
=C2=A0 =C2=A0 constant MB_ICONWARNING=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x00000=
030;<br>
=C2=A0 =C2=A0 constant MB_ICONINFORMATION=C2=A0 =C2=A0=3D 0x00000040;<br>
=C2=A0 =C2=A0 constant MB_ICONASTERISK=C2=A0 =C2=A0 =C2=A0 =3D 0x00000040;<=
br>
=C2=A0 =C2=A0 constant MB_ICONQUESTION=C2=A0 =C2=A0 =C2=A0 =3D 0x00000020;<=
br>
=C2=A0 =C2=A0 constant MB_ICONSTOP=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0x=
00000010;<br>
=C2=A0 =C2=A0 constant MB_ICONERROR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x=
00000010;<br>
=C2=A0 =C2=A0 constant MB_ICONHAND=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0x=
00000010;<br>
<br>
<br>
=C2=A0 =C2=A0 constant MB_ABORTRETRYIGNORE=C2=A0 =3D 0x00000002;<br>
=C2=A0 =C2=A0 constant MB_CANCELTRYCONTINUE =3D 0x00000006;<br>
=C2=A0 =C2=A0 constant MB_HELP=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =3D 0x00004000;<br>
=C2=A0 =C2=A0 constant MB_OK=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =3D 0x00000000;<br>
=C2=A0 =C2=A0 constant MB_OKCANCEL=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0x=
00000001;<br>
=C2=A0 =C2=A0 constant MB_RETRYCANCEL=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x00000=
005;<br>
=C2=A0 =C2=A0 constant MB_YESNO=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0=3D 0x00000004;<br>
=C2=A0 =C2=A0 constant MB_YESNOCANCEL=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x00000=
003;<br>
<br>
=C2=A0 =C2=A0 constant DABORT=C2=A0 =C2=A0 =C2=A0=3D=C2=A0 3;<br>
=C2=A0 =C2=A0 constant IDCANCEL=C2=A0 =C2=A0=3D=C2=A0 2;<br>
=C2=A0 =C2=A0 constant IDCONTINUE =3D 11;<br>
=C2=A0 =C2=A0 constant IDIGNORE=C2=A0 =C2=A0=3D=C2=A0 5;<br>
=C2=A0 =C2=A0 constant IDNO=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D=C2=A0 7;<br>
=C2=A0 =C2=A0 constant IDOK=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D=C2=A0 1;<br>
=C2=A0 =C2=A0 constant IDRETRY=C2=A0 =C2=A0 =3D=C2=A0 4;<br>
=C2=A0 =C2=A0 constant IDTRYAGAIN =3D 10;<br>
=C2=A0 =C2=A0 constant IDYES=C2=A0 =C2=A0 =C2=A0 =3D=C2=A0 6;<br>
<br>
<br>
=C2=A0 =C2=A0 # Note: the following two subs have to be embedded<br>
<br>
=C2=A0 =C2=A0 sub MessageBoxW( HANDLE, LPWCTSTR, LPWCTSTR, UINT ) is <br>
native(&#39;user32&#39;) returns INT { * };<br>
<br>
=C2=A0 =C2=A0 sub to-c-str( Str $str ) returns CArray[WCHAR]=C2=A0 {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0my @str :=3D CArray[WCHAR].new;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0for ( $str.comb ).kv -&gt; $i, $char { @str[$i] =
=3D $char.ord; }<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0@str[ $str.chars ] =3D 0;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0@str;<br>
=C2=A0 =C2=A0 }<br>
<br>
<br>
=C2=A0 =C2=A0 if=C2=A0 =C2=A0 =C2=A0$Icons eq &quot;Exclamation&quot;=C2=A0=
 { $IconInt =3D MB_ICONEXCLAMATION; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Warning&quot;=C2=A0 =C2=A0 =C2=A0=
 { $IconInt =3D MB_ICONWARNING; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Information&quot;=C2=A0 { $IconIn=
t =3D MB_ICONINFORMATION; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Asterisk&quot;=C2=A0 =C2=A0 =C2=
=A0{ $IconInt =3D MB_ICONASTERISK; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Question&quot;=C2=A0 =C2=A0 =C2=
=A0{ $IconInt =3D MB_ICONQUESTION; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Stop&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0{ $IconInt =3D MB_ICONSTOP; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Error&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 { $IconInt =3D MB_ICONERROR; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Hand&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0{ $IconInt =3D MB_ICONHAND; }<br>
<br>
=C2=A0 =C2=A0 if=C2=A0 =C2=A0 =C2=A0$Buttons eq &quot;AbortRetryIgnore&quot=
;=C2=A0 =C2=A0 =C2=A0 =C2=A0{ $ButtonInt =3D <br>
MB_ABORTRETRYIGNORE; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;CancelTryAgainContinue&quot; { =
$ButtonInt =3D <br>
MB_CANCELTRYCONTINUE; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;Help&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{ $ButtonInt =3D MB_HELP; }=
<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;Ok&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{ $ButtonInt =3D MB_=
OK; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;OkCancel&quot;=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{ $ButtonInt =3D <br>
MB_OKCANCEL; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;RetryCancel&quot;=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 { $ButtonInt =3D <br>
MB_RETRYCANCEL; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;YesNo&quot;=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 { $ButtonInt =3D MB_YESNO; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;YesNoCancel&quot;=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 { $ButtonInt =3D <br>
MB_YESNOCANCEL; }<br>
<br>
=C2=A0 =C2=A0 $UINT =3D $IconInt +| $ButtonInt;=C2=A0 =C2=A0# Bitwise OR th=
em together<br>
<br>
=C2=A0 =C2=A0 $RtnInt =3D MessageBoxW( my $handle, to-c-str( $MessageStr ),=
 <br>
to-c-str( $TitleStr ), $UINT );<br>
<br>
=C2=A0 =C2=A0 # say $RtnInt;<br>
=C2=A0 =C2=A0 if=C2=A0 =C2=A0 =C2=A0$RtnInt =3D=3D DABORT=C2=A0 =C2=A0 =C2=
=A0 { $RtnStr =3D &quot;Abort&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDCANCEL=C2=A0 =C2=A0 { $RtnStr =
=3D &quot;Cancel&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDCONTINUE=C2=A0 { $RtnStr =3D &qu=
ot;Continue&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDIGNORE=C2=A0 =C2=A0 { $RtnStr =
=3D &quot;Ignore&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDNO=C2=A0 =C2=A0 =C2=A0 =C2=A0 { =
$RtnStr =3D &quot;No&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDOK=C2=A0 =C2=A0 =C2=A0 =C2=A0 { =
$RtnStr =3D &quot;Ok&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDRETRY=C2=A0 =C2=A0 =C2=A0{ $RtnS=
tr =3D &quot;Retry&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDTRYAGAIN=C2=A0 { $RtnStr =3D &qu=
ot;Try Again&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDYES=C2=A0 =C2=A0 =C2=A0 =C2=A0{ =
$RtnStr =3D &quot;Yes&quot;; }<br>
<br>
=C2=A0 =C2=A0 return $RtnStr;<br>
}<br>
<br>
<br>
sub WinMsg( Str $TitleStr, Str $MessageStr ) is export( :WinMsg )=C2=A0 {<b=
r>
<br>
#`{<br>
=C2=A0 =C2=A0 =C2=A0 Simple &quot;Ok&quot; pop up with no return value<br>
<br>
=C2=A0 =C2=A0 =C2=A0 Test one liner:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 perl6 -e &quot;use lib &#39;.&#39;; use =
WinPopUps :WinPopUp, :WinMsg; <br>
WinMsg( &#39;Super Duper Title&#39;, &#39;What? You were expecting somethin=
g witty?&#39; );&quot;<br>
<br>
}<br>
<br>
=C2=A0 =C2=A0 WinPopUp( $TitleStr, $MessageStr, &quot;Information&quot;, &q=
uot;Ok&quot; );<br>
<br>
}<br>
&lt;/WinpopUps.pm6&gt;<br>
</blockquote></div></div>

--0000000000004575ca05991c3d4e--
0
tom
12/7/2019 12:23:57 PM
--0000000000008fa4cc059aaa42af
Content-Type: text/plain; charset="UTF-8"

Hi Todd,
I refactored your code a bit to make it a bit more readable IMHO. Thinking
on publish it on modules.raku.org if you are not interested to do so.

#`{
       Reference:

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox

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

use NativeCall;

enum Icons (
        MB_ICONEXCLAMATION   => 0x00000030,
        MB_ICONWARNING       => 0x00000030,
        MB_ICONINFORMATION   => 0x00000040,
        MB_ICONASTERISK      => 0x00000040,
        MB_ICONQUESTION      => 0x00000020,
        MB_ICONSTOP          => 0x00000010,
        MB_ICONERROR         => 0x00000010,
        MB_ICONHAND          => 0x00000010
);

enum Buttons (
        MB_ABORTRETRYIGNORE  => 0x00000002,
        MB_CANCELTRYCONTINUE => 0x00000006,
        MB_HELP              => 0x00004000,
        MB_OK                => 0x00000000,
        MB_OKCANCEL          => 0x00000001,
        MB_RETRYCANCEL       => 0x00000005,
        MB_YESNO             => 0x00000004,
        MB_YESNOCANCEL       => 0x00000003
);

enum MessageBoxReturn (
        DABORT     =>  3,
        IDCANCEL   =>  2,
        IDCONTINUE => 11,
        IDIGNORE   =>  5,
        IDNO       =>  7,
        IDOK       =>  1,
        IDRETRY    =>  4,
        IDTRYAGAIN => 10,
        IDYES      =>  6
);

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

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;
}

sub MessageBox(Str $title, Str $message, Icons $icon =
Icons::MB_ICONINFORMATION, Buttons $button = Buttons::MB_OK) returns
MessageBoxReturn is export
{
   my Str $SubName = &?ROUTINE.name;
    my Str $OS      = $*KERNEL.name;

    if not $OS eq "win32" { say "Sorry, $SubName only work in Windows.";
    exit; }

    MessageBoxReturn(MessageBoxW( my $handle, to-c-str( $message ),
to-c-str( $title ), $icon +| $button ));
}


On Sat, 7 Dec 2019 at 13:36, Tom Browder <tom.browder@gmail.com> wrote:

> On Sat, Dec 7, 2019 at 05:41 ToddAndMargo via perl6-users <
> perl6-users@perl.org> wrote:
>
>> Hi All,
>>
>> I wrote and extensive module for pop up in Windows.
>
>
> Todd, you need to publish your module to the Raku module ecosystem. Many
> people, including myself, want to see an easily-installable module with at
> least some basic tests to give strangers confidence that it will not blow
> up. Instructions are in the docs, and there are helper modules to get you
> started.
>
> I'll send you specific doc references later when I get a chance, but it's
> probably better for you to dig around the doc site a bit more on your own.
> Hint: in the search box, enter 'module'.
>
> -Tom
>
>
>>
>> It does not contain a time out option.  Maybe some day I
>> will work on the timer function.
>>
>> Thank you all for helping me with various parts of this!
>>
>> There are basically two subs to import
>>      WinMsg  and  WinPopUp
>>
>> Here are some one liners to test it with:
>>
>> perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp( 'Super
>> Duper Title', 'What? You were expecting something witty?',
>> 'Information', 'Ok'  );"
>>
>> perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp( 'Super
>> Duper Title', 'What? You were expecting something witty?', 'Question',
>> 'YesNoCancel' );
>>
>> perl6 -e "use lib '.'; use WinPopUps :WinPopUp, :WinMsg; WinMsg( 'Super
>> Duper Title', 'What? You were expecting something witty?' );"
>>
>> Let me know if you find any booboo's.
>>
>> -T
>>
>>
>> <WinPopUps.pm6>
>> # unit module WinPopUps;
>> # WinMsg.pm6
>>
>> #`{
>>        Reference:
>>
>>
>> https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox
>>
>>
>> https://stackoverflow.com/questions/59105696/how-can-i-create-pop-up-windows-for-perl6-in-windows
>> }
>>
>> use NativeCall;
>>
>> sub WinPopUp( Str $TitleStr,
>>                Str $MessageStr,
>>                Str $Icons where   * ~~ "Exclamation"             |
>>                                        "Warning"                 |
>>                                        "Information"             |
>>                                        "Asterisk"                |
>>                                        "Question"                |
>>                                        "Stop"                    |
>>                                        "Error"                   |
>>                                        "Hand",
>>                Str $Buttons where * ~~ "AbortRetryIgnore"        |
>>                                        "CancelTryAgainContinue"  |
>>                                        "Help"                    |
>>                                        "Ok"                      |
>>                                        "OkCancel"                |
>>                                        "RetryCancel"             |
>>                                        "YesNo"                   |
>>                                        "YesNoCancel" )
>>                is export( :WinPopUp ) {
>>
>> #`{
>>
>>      Pop up a message box to the user.  Windows only.
>>      Return what button was pressed
>>
>>      Note: you are constrainedthe the Icon and Button values shown in
>> the sub declaration.
>>
>>      Test one liners:
>>          perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp(
>> 'Super Duper Title', 'What? You were expecting something witty?',
>> 'Information', 'Ok'  );"
>>          perl6 -e "use lib '.'; use WinPopUps :WinPopUp; say WinPopUp(
>> 'Super Duper Title', 'What? You were expecting something witty?',
>> 'Question', 'YesNoCancel' );
>>
>> }
>>
>>     my Str $SubName = &?ROUTINE.name;
>>     my Str $OS      = $*KERNEL.name;
>>
>>     if not $OS eq "win32" { say "Sorry, $SubName only work in Windows.";
>> exit; }
>>     my int32 $RtnInt = 0;
>>     my Str   $RtnStr = "";
>>     my int32 $IconInt;
>>     my int32 $ButtonInt;
>>     my int32 $UINT;
>>
>>     # Note: these constants are 32 bit
>>     constant WCHAR              = uint16;
>>     constant INT                = int32;
>>     constant UINT               = uint32;
>>     constant HANDLE             = Pointer[void];
>>     constant LPWCTSTR           = CArray[WCHAR];
>>
>>
>>     constant MB_ICONEXCLAMATION   = 0x00000030;
>>     constant MB_ICONWARNING       = 0x00000030;
>>     constant MB_ICONINFORMATION   = 0x00000040;
>>     constant MB_ICONASTERISK      = 0x00000040;
>>     constant MB_ICONQUESTION      = 0x00000020;
>>     constant MB_ICONSTOP          = 0x00000010;
>>     constant MB_ICONERROR         = 0x00000010;
>>     constant MB_ICONHAND          = 0x00000010;
>>
>>
>>     constant MB_ABORTRETRYIGNORE  = 0x00000002;
>>     constant MB_CANCELTRYCONTINUE = 0x00000006;
>>     constant MB_HELP              = 0x00004000;
>>     constant MB_OK                = 0x00000000;
>>     constant MB_OKCANCEL          = 0x00000001;
>>     constant MB_RETRYCANCEL       = 0x00000005;
>>     constant MB_YESNO             = 0x00000004;
>>     constant MB_YESNOCANCEL       = 0x00000003;
>>
>>     constant DABORT     =  3;
>>     constant IDCANCEL   =  2;
>>     constant IDCONTINUE = 11;
>>     constant IDIGNORE   =  5;
>>     constant IDNO       =  7;
>>     constant IDOK       =  1;
>>     constant IDRETRY    =  4;
>>     constant IDTRYAGAIN = 10;
>>     constant IDYES      =  6;
>>
>>
>>     # 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;
>>     }
>>
>>
>>     if     $Icons eq "Exclamation"  { $IconInt = MB_ICONEXCLAMATION; }
>>     elsif  $Icons eq "Warning"      { $IconInt = MB_ICONWARNING; }
>>     elsif  $Icons eq "Information"  { $IconInt = MB_ICONINFORMATION; }
>>     elsif  $Icons eq "Asterisk"     { $IconInt = MB_ICONASTERISK; }
>>     elsif  $Icons eq "Question"     { $IconInt = MB_ICONQUESTION; }
>>     elsif  $Icons eq "Stop"         { $IconInt = MB_ICONSTOP; }
>>     elsif  $Icons eq "Error"        { $IconInt = MB_ICONERROR; }
>>     elsif  $Icons eq "Hand"         { $IconInt = MB_ICONHAND; }
>>
>>     if     $Buttons eq "AbortRetryIgnore"       { $ButtonInt =
>> MB_ABORTRETRYIGNORE; }
>>     elsif  $Buttons eq "CancelTryAgainContinue" { $ButtonInt =
>> MB_CANCELTRYCONTINUE; }
>>     elsif  $Buttons eq "Help"                   { $ButtonInt = MB_HELP; }
>>     elsif  $Buttons eq "Ok"                     { $ButtonInt = MB_OK; }
>>     elsif  $Buttons eq "OkCancel"               { $ButtonInt =
>> MB_OKCANCEL; }
>>     elsif  $Buttons eq "RetryCancel"            { $ButtonInt =
>> MB_RETRYCANCEL; }
>>     elsif  $Buttons eq "YesNo"                  { $ButtonInt = MB_YESNO; }
>>     elsif  $Buttons eq "YesNoCancel"            { $ButtonInt =
>> MB_YESNOCANCEL; }
>>
>>     $UINT = $IconInt +| $ButtonInt;   # Bitwise OR them together
>>
>>     $RtnInt = MessageBoxW( my $handle, to-c-str( $MessageStr ),
>> to-c-str( $TitleStr ), $UINT );
>>
>>     # say $RtnInt;
>>     if     $RtnInt == DABORT      { $RtnStr = "Abort"; }
>>     elsif  $RtnInt == IDCANCEL    { $RtnStr = "Cancel"; }
>>     elsif  $RtnInt == IDCONTINUE  { $RtnStr = "Continue"; }
>>     elsif  $RtnInt == IDIGNORE    { $RtnStr = "Ignore"; }
>>     elsif  $RtnInt == IDNO        { $RtnStr = "No"; }
>>     elsif  $RtnInt == IDOK        { $RtnStr = "Ok"; }
>>     elsif  $RtnInt == IDRETRY     { $RtnStr = "Retry"; }
>>     elsif  $RtnInt == IDTRYAGAIN  { $RtnStr = "Try Again"; }
>>     elsif  $RtnInt == IDYES       { $RtnStr = "Yes"; }
>>
>>     return $RtnStr;
>> }
>>
>>
>> sub WinMsg( Str $TitleStr, Str $MessageStr ) is export( :WinMsg )  {
>>
>> #`{
>>       Simple "Ok" pop up with no return value
>>
>>       Test one liner:
>>           perl6 -e "use lib '.'; use WinPopUps :WinPopUp, :WinMsg;
>> WinMsg( 'Super Duper Title', 'What? You were expecting something witty?'
>> );"
>>
>> }
>>
>>     WinPopUp( $TitleStr, $MessageStr, "Information", "Ok" );
>>
>> }
>> </WinpopUps.pm6>
>>
>

--0000000000008fa4cc059aaa42af
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi Todd,</div><div>I refactored your code a bit to ma=
ke it a bit more readable IMHO. Thinking on publish it on <a href=3D"http:/=
/modules.raku.org">modules.raku.org</a> if you are not interested to do so.=
</div><div><br></div><div><pre style=3D"background-color:rgb(43,43,43);colo=
r:rgb(169,183,198);font-family:&quot;DejaVu Sans Mono&quot;;font-size:9pt">=
#`{<span style=3D"color:rgb(128,128,128)"><br></span><span style=3D"color:r=
gb(128,128,128)">       Reference:<br></span><span style=3D"color:rgb(128,1=
28,128)"><br></span><span style=3D"color:rgb(128,128,128)"><a href=3D"https=
://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox=
">https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mes=
sagebox</a><br></span><span style=3D"color:rgb(128,128,128)"><br></span><sp=
an style=3D"color:rgb(128,128,128)"><a href=3D"https://stackoverflow.com/qu=
estions/59105696/how-can-i-create-pop-up-windows-for-perl6-in-windows">http=
s://stackoverflow.com/questions/59105696/how-can-i-create-pop-up-windows-fo=
r-perl6-in-windows</a><br></span>}<br><br><span style=3D"color:rgb(204,120,=
50)">use </span><span style=3D"color:rgb(196,68,142)">NativeCall</span><spa=
n style=3D"color:rgb(204,120,50)">;<br></span><span style=3D"color:rgb(204,=
120,50)"><br></span><span style=3D"color:rgb(204,120,50)">enum </span><span=
 style=3D"color:rgb(196,68,142)">Icons </span>(<br>        <span style=3D"c=
olor:rgb(106,135,89)">MB_ICONEXCLAMATION   </span><span style=3D"color:rgb(=
187,181,41)">=3D&gt; </span><span style=3D"color:rgb(104,151,187)">0x000000=
30</span><span style=3D"color:rgb(187,181,41)">,<br></span><span style=3D"c=
olor:rgb(187,181,41)">        </span><span style=3D"color:rgb(106,135,89)">=
MB_ICONWARNING       </span><span style=3D"color:rgb(187,181,41)">=3D&gt; <=
/span><span style=3D"color:rgb(104,151,187)">0x00000030</span><span style=
=3D"color:rgb(187,181,41)">,<br></span><span style=3D"color:rgb(187,181,41)=
">        </span><span style=3D"color:rgb(106,135,89)">MB_ICONINFORMATION  =
 </span><span style=3D"color:rgb(187,181,41)">=3D&gt; </span><span style=3D=
"color:rgb(104,151,187)">0x00000040</span><span style=3D"color:rgb(187,181,=
41)">,<br></span><span style=3D"color:rgb(187,181,41)">        </span><span=
 style=3D"color:rgb(106,135,89)">MB_ICONASTERISK      </span><span style=3D=
"color:rgb(187,181,41)">=3D&gt; </span><span style=3D"color:rgb(104,151,187=
)">0x00000040</span><span style=3D"color:rgb(187,181,41)">,<br></span><span=
 style=3D"color:rgb(187,181,41)">        </span><span style=3D"color:rgb(10=
6,135,89)">MB_ICONQUESTION      </span><span style=3D"color:rgb(187,181,41)=
">=3D&gt; </span><span style=3D"color:rgb(104,151,187)">0x00000020</span><s=
pan style=3D"color:rgb(187,181,41)">,<br></span><span style=3D"color:rgb(18=
7,181,41)">        </span><span style=3D"color:rgb(106,135,89)">MB_ICONSTOP=
          </span><span style=3D"color:rgb(187,181,41)">=3D&gt; </span><span=
 style=3D"color:rgb(104,151,187)">0x00000010</span><span style=3D"color:rgb=
(187,181,41)">,<br></span><span style=3D"color:rgb(187,181,41)">        </s=
pan><span style=3D"color:rgb(106,135,89)">MB_ICONERROR         </span><span=
 style=3D"color:rgb(187,181,41)">=3D&gt; </span><span style=3D"color:rgb(10=
4,151,187)">0x00000010</span><span style=3D"color:rgb(187,181,41)">,<br></s=
pan><span style=3D"color:rgb(187,181,41)">        </span><span style=3D"col=
or:rgb(106,135,89)">MB_ICONHAND          </span><span style=3D"color:rgb(18=
7,181,41)">=3D&gt; </span><span style=3D"color:rgb(104,151,187)">0x00000010=
<br></span>)<span style=3D"color:rgb(204,120,50)">;<br></span><span style=
=3D"color:rgb(204,120,50)"><br></span><span style=3D"color:rgb(204,120,50)"=
>enum </span><span style=3D"color:rgb(196,68,142)">Buttons </span>(<br>    =
    <span style=3D"color:rgb(106,135,89)">MB_ABORTRETRYIGNORE  </span><span=
 style=3D"color:rgb(187,181,41)">=3D&gt; </span><span style=3D"color:rgb(10=
4,151,187)">0x00000002</span><span style=3D"color:rgb(187,181,41)">,<br></s=
pan><span style=3D"color:rgb(187,181,41)">        </span><span style=3D"col=
or:rgb(106,135,89)">MB_CANCELTRYCONTINUE </span><span style=3D"color:rgb(18=
7,181,41)">=3D&gt; </span><span style=3D"color:rgb(104,151,187)">0x00000006=
</span><span style=3D"color:rgb(187,181,41)">,<br></span><span style=3D"col=
or:rgb(187,181,41)">        </span><span style=3D"color:rgb(106,135,89)">MB=
_HELP              </span><span style=3D"color:rgb(187,181,41)">=3D&gt; </s=
pan><span style=3D"color:rgb(104,151,187)">0x00004000</span><span style=3D"=
color:rgb(187,181,41)">,<br></span><span style=3D"color:rgb(187,181,41)">  =
      </span><span style=3D"color:rgb(106,135,89)">MB_OK                </s=
pan><span style=3D"color:rgb(187,181,41)">=3D&gt; </span><span style=3D"col=
or:rgb(104,151,187)">0x00000000</span><span style=3D"color:rgb(187,181,41)"=
>,<br></span><span style=3D"color:rgb(187,181,41)">        </span><span sty=
le=3D"color:rgb(106,135,89)">MB_OKCANCEL          </span><span style=3D"col=
or:rgb(187,181,41)">=3D&gt; </span><span style=3D"color:rgb(104,151,187)">0=
x00000001</span><span style=3D"color:rgb(187,181,41)">,<br></span><span sty=
le=3D"color:rgb(187,181,41)">        </span><span style=3D"color:rgb(106,13=
5,89)">MB_RETRYCANCEL       </span><span style=3D"color:rgb(187,181,41)">=
=3D&gt; </span><span style=3D"color:rgb(104,151,187)">0x00000005</span><spa=
n style=3D"color:rgb(187,181,41)">,<br></span><span style=3D"color:rgb(187,=
181,41)">        </span><span style=3D"color:rgb(106,135,89)">MB_YESNO     =
        </span><span style=3D"color:rgb(187,181,41)">=3D&gt; </span><span s=
tyle=3D"color:rgb(104,151,187)">0x00000004</span><span style=3D"color:rgb(1=
87,181,41)">,<br></span><span style=3D"color:rgb(187,181,41)">        </spa=
n><span style=3D"color:rgb(106,135,89)">MB_YESNOCANCEL       </span><span s=
tyle=3D"color:rgb(187,181,41)">=3D&gt; </span><span style=3D"color:rgb(104,=
151,187)">0x00000003<br></span>)<span style=3D"color:rgb(204,120,50)">;<br>=
</span><span style=3D"color:rgb(204,120,50)"><br></span><span style=3D"colo=
r:rgb(204,120,50)">enum </span><span style=3D"color:rgb(196,68,142)">Messag=
eBoxReturn </span>(<br>        <span style=3D"color:rgb(106,135,89)">DABORT=
     </span><span style=3D"color:rgb(187,181,41)">=3D&gt;  </span><span sty=
le=3D"color:rgb(104,151,187)">3</span><span style=3D"color:rgb(187,181,41)"=
>,<br></span><span style=3D"color:rgb(187,181,41)">        </span><span sty=
le=3D"color:rgb(106,135,89)">IDCANCEL   </span><span style=3D"color:rgb(187=
,181,41)">=3D&gt;  </span><span style=3D"color:rgb(104,151,187)">2</span><s=
pan style=3D"color:rgb(187,181,41)">,<br></span><span style=3D"color:rgb(18=
7,181,41)">        </span><span style=3D"color:rgb(106,135,89)">IDCONTINUE =
</span><span style=3D"color:rgb(187,181,41)">=3D&gt; </span><span style=3D"=
color:rgb(104,151,187)">11</span><span style=3D"color:rgb(187,181,41)">,<br=
></span><span style=3D"color:rgb(187,181,41)">        </span><span style=3D=
"color:rgb(106,135,89)">IDIGNORE   </span><span style=3D"color:rgb(187,181,=
41)">=3D&gt;  </span><span style=3D"color:rgb(104,151,187)">5</span><span s=
tyle=3D"color:rgb(187,181,41)">,<br></span><span style=3D"color:rgb(187,181=
,41)">        </span><span style=3D"color:rgb(106,135,89)">IDNO       </spa=
n><span style=3D"color:rgb(187,181,41)">=3D&gt;  </span><span style=3D"colo=
r:rgb(104,151,187)">7</span><span style=3D"color:rgb(187,181,41)">,<br></sp=
an><span style=3D"color:rgb(187,181,41)">        </span><span style=3D"colo=
r:rgb(106,135,89)">IDOK       </span><span style=3D"color:rgb(187,181,41)">=
=3D&gt;  </span><span style=3D"color:rgb(104,151,187)">1</span><span style=
=3D"color:rgb(187,181,41)">,<br></span><span style=3D"color:rgb(187,181,41)=
">        </span><span style=3D"color:rgb(106,135,89)">IDRETRY    </span><s=
pan style=3D"color:rgb(187,181,41)">=3D&gt;  </span><span style=3D"color:rg=
b(104,151,187)">4</span><span style=3D"color:rgb(187,181,41)">,<br></span><=
span style=3D"color:rgb(187,181,41)">        </span><span style=3D"color:rg=
b(106,135,89)">IDTRYAGAIN </span><span style=3D"color:rgb(187,181,41)">=3D&=
gt; </span><span style=3D"color:rgb(104,151,187)">10</span><span style=3D"c=
olor:rgb(187,181,41)">,<br></span><span style=3D"color:rgb(187,181,41)">   =
     </span><span style=3D"color:rgb(106,135,89)">IDYES      </span><span s=
tyle=3D"color:rgb(187,181,41)">=3D&gt;  </span><span style=3D"color:rgb(104=
,151,187)">6<br></span>)<span style=3D"color:rgb(204,120,50)">;<br></span><=
span style=3D"color:rgb(204,120,50)"><br></span><span style=3D"color:rgb(20=
4,120,50)">constant </span><span style=3D"color:rgb(196,68,142)">WCHAR     =
         </span><span style=3D"color:rgb(187,181,41)">=3D </span><span styl=
e=3D"color:rgb(196,68,142)">uint16</span><span style=3D"color:rgb(204,120,5=
0)">;<br></span><span style=3D"color:rgb(204,120,50)">constant </span><span=
 style=3D"color:rgb(196,68,142)">INT                </span><span style=3D"c=
olor:rgb(187,181,41)">=3D </span><span style=3D"color:rgb(196,68,142)">int3=
2</span><span style=3D"color:rgb(204,120,50)">;<br></span><span style=3D"co=
lor:rgb(204,120,50)">constant </span><span style=3D"color:rgb(196,68,142)">=
UINT               </span><span style=3D"color:rgb(187,181,41)">=3D </span>=
<span style=3D"color:rgb(196,68,142)">uint32</span><span style=3D"color:rgb=
(204,120,50)">;<br></span><span style=3D"color:rgb(204,120,50)">constant </=
span><span style=3D"color:rgb(196,68,142)">HANDLE             </span><span =
style=3D"color:rgb(187,181,41)">=3D </span><span style=3D"color:rgb(196,68,=
142)">Pointer</span>[<span style=3D"color:rgb(255,198,109)">void</span>]<sp=
an style=3D"color:rgb(204,120,50)">;<br></span><span style=3D"color:rgb(204=
,120,50)">constant </span><span style=3D"color:rgb(196,68,142)">LPWCTSTR   =
        </span><span style=3D"color:rgb(187,181,41)">=3D </span><span style=
=3D"color:rgb(196,68,142)">CArray</span>[<span style=3D"color:rgb(196,68,14=
2)">WCHAR</span>]<span style=3D"color:rgb(204,120,50)">;<br></span><span st=
yle=3D"color:rgb(204,120,50)"><br></span><span style=3D"color:rgb(204,120,5=
0)">sub </span><span style=3D"color:rgb(255,198,109)">MessageBoxW</span>( <=
span style=3D"color:rgb(196,68,142)">HANDLE</span>, <span style=3D"color:rg=
b(196,68,142)">LPWCTSTR</span>, <span style=3D"color:rgb(196,68,142)">LPWCT=
STR</span>, <span style=3D"color:rgb(196,68,142)">UINT </span>) <span style=
=3D"color:rgb(204,120,50)">is<br></span><span style=3D"color:rgb(204,120,50=
)">        </span><span style=3D"color:rgb(196,68,142)">native</span>(<span=
 style=3D"color:rgb(106,135,89)">&#39;user32&#39;</span>) <span style=3D"co=
lor:rgb(204,120,50)">returns </span><span style=3D"color:rgb(196,68,142)">I=
NT </span>{ * }<span style=3D"color:rgb(204,120,50)">;<br></span><span styl=
e=3D"color:rgb(204,120,50)"><br></span><span style=3D"color:rgb(204,120,50)=
">sub </span><span style=3D"color:rgb(255,198,109)">to-c-str</span>( <span =
style=3D"color:rgb(196,68,142)">Str </span><span style=3D"color:rgb(152,118=
,170)">$str </span>) <span style=3D"color:rgb(204,120,50)">returns </span><=
span style=3D"color:rgb(196,68,142)">CArray[WCHAR]  </span>{<br>    <span s=
tyle=3D"color:rgb(204,120,50)">my </span><span style=3D"color:rgb(152,118,1=
70)">@str </span><span style=3D"color:rgb(187,181,41)">:=3D </span><span st=
yle=3D"color:rgb(196,68,142)">CArray</span>[<span style=3D"color:rgb(196,68=
,142)">WCHAR</span>]<span style=3D"color:rgb(187,181,41)">.</span><span sty=
le=3D"color:rgb(255,198,109)">new</span><span style=3D"color:rgb(204,120,50=
)">;<br></span><span style=3D"color:rgb(204,120,50)">    for </span>( <span=
 style=3D"color:rgb(152,118,170)">$str</span><span style=3D"color:rgb(187,1=
81,41)">.</span><span style=3D"color:rgb(255,198,109)">comb </span>)<span s=
tyle=3D"color:rgb(187,181,41)">.</span><span style=3D"color:rgb(255,198,109=
)">kv </span>-&gt; <span style=3D"color:rgb(152,118,170)">$i</span>, <span =
style=3D"color:rgb(152,118,170)">$char </span>{ <span style=3D"color:rgb(15=
2,118,170)">@str</span>[<span style=3D"color:rgb(152,118,170)">$i</span>] <=
span style=3D"color:rgb(187,181,41)">=3D </span><span style=3D"color:rgb(15=
2,118,170)">$char</span><span style=3D"color:rgb(187,181,41)">.</span><span=
 style=3D"color:rgb(255,198,109)">ord</span><span style=3D"color:rgb(204,12=
0,50)">; </span>}<br>    <span style=3D"color:rgb(152,118,170)">@str</span>=
[ <span style=3D"color:rgb(152,118,170)">$str</span><span style=3D"color:rg=
b(187,181,41)">.</span><span style=3D"color:rgb(255,198,109)">chars </span>=
] <span style=3D"color:rgb(187,181,41)">=3D </span><span style=3D"color:rgb=
(104,151,187)">0</span><span style=3D"color:rgb(204,120,50)">;<br></span><s=
pan style=3D"color:rgb(204,120,50)">    </span><span style=3D"color:rgb(152=
,118,170)">@str</span><span style=3D"color:rgb(204,120,50)">;<br></span>}<b=
r><br><span style=3D"color:rgb(204,120,50)">sub </span><span style=3D"color=
:rgb(255,198,109)">MessageBox</span>(<span style=3D"color:rgb(196,68,142)">=
Str </span><span style=3D"color:rgb(152,118,170)">$title</span>, <span styl=
e=3D"color:rgb(196,68,142)">Str </span><span style=3D"color:rgb(152,118,170=
)">$message</span>, <span style=3D"color:rgb(196,68,142)">Icons </span><spa=
n style=3D"color:rgb(152,118,170)">$icon </span><span style=3D"color:rgb(18=
7,181,41)">=3D </span><span style=3D"color:rgb(196,68,142)">Icons::MB_ICONI=
NFORMATION</span>, <span style=3D"color:rgb(196,68,142)">Buttons </span><sp=
an style=3D"color:rgb(152,118,170)">$button </span><span style=3D"color:rgb=
(187,181,41)">=3D </span><span style=3D"color:rgb(196,68,142)">Buttons::MB_=
OK</span>) <span style=3D"color:rgb(204,120,50)">returns </span><span style=
=3D"color:rgb(196,68,142)">MessageBoxReturn </span><span style=3D"color:rgb=
(204,120,50)">is </span><span style=3D"color:rgb(196,68,142)">export<br></s=
pan>{<br>   <span style=3D"color:rgb(204,120,50)">my </span><span style=3D"=
color:rgb(196,68,142)">Str </span><span style=3D"color:rgb(152,118,170)">$S=
ubName </span><span style=3D"color:rgb(187,181,41)">=3D </span><span style=
=3D"color:rgb(152,118,170)">&amp;?ROUTINE</span><span style=3D"color:rgb(18=
7,181,41)">.</span><span style=3D"color:rgb(255,198,109)">name</span><span =
style=3D"color:rgb(204,120,50)">;<br></span><span style=3D"color:rgb(204,12=
0,50)">    my </span><span style=3D"color:rgb(196,68,142)">Str </span><span=
 style=3D"color:rgb(152,118,170)">$OS      </span><span style=3D"color:rgb(=
187,181,41)">=3D </span><span style=3D"color:rgb(152,118,170)">$*KERNEL</sp=
an><span style=3D"color:rgb(187,181,41)">.</span><span style=3D"color:rgb(2=
55,198,109)">name</span><span style=3D"color:rgb(204,120,50)">;<br></span><=
span style=3D"color:rgb(204,120,50)"><br></span><span style=3D"color:rgb(20=
4,120,50)">    if </span><span style=3D"color:rgb(187,181,41)">not </span><=
span style=3D"color:rgb(152,118,170)">$OS </span><span style=3D"color:rgb(1=
87,181,41)">eq </span><span style=3D"color:rgb(106,135,89)">&quot;win32&quo=
t; </span>{ <span style=3D"color:rgb(255,198,109)">say </span><span style=
=3D"color:rgb(106,135,89)">&quot;Sorry, </span><span style=3D"color:rgb(152=
,118,170)">$SubName </span><span style=3D"color:rgb(106,135,89)">only work =
in Windows.&quot;</span><span style=3D"color:rgb(204,120,50)">;<br></span><=
span style=3D"color:rgb(204,120,50)">    </span><span style=3D"color:rgb(25=
5,198,109)">exit</span><span style=3D"color:rgb(204,120,50)">; </span>}<br>=
   <br>    <span style=3D"color:rgb(255,198,109)">MessageBoxReturn</span>(<=
span style=3D"color:rgb(255,198,109)">MessageBoxW</span>( <span style=3D"co=
lor:rgb(204,120,50)">my </span><span style=3D"color:rgb(152,118,170)">$hand=
le</span><span style=3D"color:rgb(187,181,41)">, </span><span style=3D"colo=
r:rgb(255,198,109)">to-c-str</span>( <span style=3D"color:rgb(152,118,170)"=
>$message </span>)<span style=3D"color:rgb(187,181,41)">,</span> <span styl=
e=3D"color:rgb(255,198,109)">to-c-str</span>( <span style=3D"color:rgb(152,=
118,170)">$title </span>)<span style=3D"color:rgb(187,181,41)">, </span><sp=
an style=3D"color:rgb(152,118,170)">$icon </span><span style=3D"color:rgb(1=
87,181,41)">+| </span><span style=3D"color:rgb(152,118,170)">$button </span=
>))<span style=3D"color:rgb(204,120,50)">;<br></span>}<br></pre></div></div=
><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sa=
t, 7 Dec 2019 at 13:36, Tom Browder &lt;<a href=3D"mailto:tom.browder@gmail=
..com">tom.browder@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,=
204,204);padding-left:1ex"><div>On Sat, Dec 7, 2019 at 05:41 ToddAndMargo v=
ia perl6-users &lt;<a href=3D"mailto:perl6-users@perl.org" target=3D"_blank=
">perl6-users@perl.org</a>&gt; wrote:<br></div><div><div class=3D"gmail_quo=
te"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bor=
der-left:1px solid rgb(204,204,204);padding-left:1ex">Hi All,<br>
<br>
I wrote and extensive module for pop up in Windows.</blockquote><div dir=3D=
"auto"><br></div><div dir=3D"auto">Todd, you need to publish your module to=
 the Raku module ecosystem. Many people, including myself, want to see an e=
asily-installable module with at least some basic tests to give strangers c=
onfidence that it will not blow up. Instructions are in the docs, and there=
 are helper modules to get you started.</div><div dir=3D"auto"><br></div><d=
iv dir=3D"auto">I&#39;ll send you specific doc references later when I get =
a chance, but it&#39;s probably better for you to dig around the doc site a=
 bit more on your own. Hint: in the search box, enter &#39;module&#39;.</di=
v><div dir=3D"auto"><br></div><div dir=3D"auto">-Tom</div><div dir=3D"auto"=
><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.=
8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
It does not contain a time out option.=C2=A0 Maybe some day I<br>
will work on the timer function.<br>
<br>
Thank you all for helping me with various parts of this!<br>
<br>
There are basically two subs to import<br>
=C2=A0 =C2=A0 =C2=A0WinMsg=C2=A0 and=C2=A0 WinPopUp<br>
<br>
Here are some one liners to test it with:<br>
<br>
perl6 -e &quot;use lib &#39;.&#39;; use WinPopUps :WinPopUp; say WinPopUp( =
&#39;Super <br>
Duper Title&#39;, &#39;What? You were expecting something witty?&#39;, <br>
&#39;Information&#39;, &#39;Ok&#39;=C2=A0 );&quot;<br>
<br>
perl6 -e &quot;use lib &#39;.&#39;; use WinPopUps :WinPopUp; say WinPopUp( =
&#39;Super <br>
Duper Title&#39;, &#39;What? You were expecting something witty?&#39;, &#39=
;Question&#39;, <br>
&#39;YesNoCancel&#39; );<br>
<br>
perl6 -e &quot;use lib &#39;.&#39;; use WinPopUps :WinPopUp, :WinMsg; WinMs=
g( &#39;Super <br>
Duper Title&#39;, &#39;What? You were expecting something witty?&#39; );&qu=
ot;<br>
<br>
Let me know if you find any booboo&#39;s.<br>
<br>
-T<br>
<br>
<br>
&lt;WinPopUps.pm6&gt;<br>
# unit module WinPopUps;<br>
# WinMsg.pm6<br>
<br>
#`{<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0Reference:<br>
<br>
<a href=3D"https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-wi=
nuser-messagebox" rel=3D"noreferrer" target=3D"_blank">https://docs.microso=
ft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox</a><br>
<br>
<a href=3D"https://stackoverflow.com/questions/59105696/how-can-i-create-po=
p-up-windows-for-perl6-in-windows" rel=3D"noreferrer" target=3D"_blank">htt=
ps://stackoverflow.com/questions/59105696/how-can-i-create-pop-up-windows-f=
or-perl6-in-windows</a><br>
}<br>
<br>
use NativeCall;<br>
<br>
sub WinPopUp( Str $TitleStr,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Str $MessageStr,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Str $Icons where=C2=
=A0 =C2=A0* ~~ &quot;Exclamation&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0|<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;War=
ning&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|<b=
r>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Inf=
ormation&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Ast=
erisk&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Que=
stion&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Sto=
p&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Err=
or&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0|<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Han=
d&quot;,<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Str $Buttons where *=
 ~~ &quot;AbortRetryIgnore&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Can=
celTryAgainContinue&quot;=C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Hel=
p&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Ok&=
quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;OkC=
ancel&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Ret=
ryCancel&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Yes=
No&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0|<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;Yes=
NoCancel&quot; )<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0is export( :WinPopUp=
 ) {<br>
<br>
#`{<br>
<br>
=C2=A0 =C2=A0 =C2=A0Pop up a message box to the user.=C2=A0 Windows only.<b=
r>
=C2=A0 =C2=A0 =C2=A0Return what button was pressed<br>
<br>
=C2=A0 =C2=A0 =C2=A0Note: you are constrainedthe the Icon and Button values=
 shown in <br>
the sub declaration.<br>
<br>
=C2=A0 =C2=A0 =C2=A0Test one liners:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0perl6 -e &quot;use lib &#39;.&#39;; use W=
inPopUps :WinPopUp; say WinPopUp( <br>
&#39;Super Duper Title&#39;, &#39;What? You were expecting something witty?=
&#39;, <br>
&#39;Information&#39;, &#39;Ok&#39;=C2=A0 );&quot;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0perl6 -e &quot;use lib &#39;.&#39;; use W=
inPopUps :WinPopUp; say WinPopUp( <br>
&#39;Super Duper Title&#39;, &#39;What? You were expecting something witty?=
&#39;, <br>
&#39;Question&#39;, &#39;YesNoCancel&#39; );<br>
<br>
}<br>
<br>
=C2=A0 =C2=A0 my Str $SubName =3D &amp;?ROUTINE.name;<br>
=C2=A0 =C2=A0 my Str $OS=C2=A0 =C2=A0 =C2=A0 =3D $*KERNEL.name;<br>
<br>
=C2=A0 =C2=A0 if not $OS eq &quot;win32&quot; { say &quot;Sorry, $SubName o=
nly work in Windows.&quot;; <br>
exit; }<br>
=C2=A0 =C2=A0 my int32 $RtnInt =3D 0;<br>
=C2=A0 =C2=A0 my Str=C2=A0 =C2=A0$RtnStr =3D &quot;&quot;;<br>
=C2=A0 =C2=A0 my int32 $IconInt;<br>
=C2=A0 =C2=A0 my int32 $ButtonInt;<br>
=C2=A0 =C2=A0 my int32 $UINT;<br>
<br>
=C2=A0 =C2=A0 # Note: these constants are 32 bit<br>
=C2=A0 =C2=A0 constant WCHAR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =3D uint16;<br>
=C2=A0 =C2=A0 constant INT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =3D int32;<br>
=C2=A0 =C2=A0 constant UINT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0=3D uint32;<br>
=C2=A0 =C2=A0 constant HANDLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0=3D Pointer[void];<br>
=C2=A0 =C2=A0 constant LPWCTSTR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D=
 CArray[WCHAR];<br>
<br>
<br>
=C2=A0 =C2=A0 constant MB_ICONEXCLAMATION=C2=A0 =C2=A0=3D 0x00000030;<br>
=C2=A0 =C2=A0 constant MB_ICONWARNING=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x00000=
030;<br>
=C2=A0 =C2=A0 constant MB_ICONINFORMATION=C2=A0 =C2=A0=3D 0x00000040;<br>
=C2=A0 =C2=A0 constant MB_ICONASTERISK=C2=A0 =C2=A0 =C2=A0 =3D 0x00000040;<=
br>
=C2=A0 =C2=A0 constant MB_ICONQUESTION=C2=A0 =C2=A0 =C2=A0 =3D 0x00000020;<=
br>
=C2=A0 =C2=A0 constant MB_ICONSTOP=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0x=
00000010;<br>
=C2=A0 =C2=A0 constant MB_ICONERROR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x=
00000010;<br>
=C2=A0 =C2=A0 constant MB_ICONHAND=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0x=
00000010;<br>
<br>
<br>
=C2=A0 =C2=A0 constant MB_ABORTRETRYIGNORE=C2=A0 =3D 0x00000002;<br>
=C2=A0 =C2=A0 constant MB_CANCELTRYCONTINUE =3D 0x00000006;<br>
=C2=A0 =C2=A0 constant MB_HELP=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =3D 0x00004000;<br>
=C2=A0 =C2=A0 constant MB_OK=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =3D 0x00000000;<br>
=C2=A0 =C2=A0 constant MB_OKCANCEL=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0x=
00000001;<br>
=C2=A0 =C2=A0 constant MB_RETRYCANCEL=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x00000=
005;<br>
=C2=A0 =C2=A0 constant MB_YESNO=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0=3D 0x00000004;<br>
=C2=A0 =C2=A0 constant MB_YESNOCANCEL=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x00000=
003;<br>
<br>
=C2=A0 =C2=A0 constant DABORT=C2=A0 =C2=A0 =C2=A0=3D=C2=A0 3;<br>
=C2=A0 =C2=A0 constant IDCANCEL=C2=A0 =C2=A0=3D=C2=A0 2;<br>
=C2=A0 =C2=A0 constant IDCONTINUE =3D 11;<br>
=C2=A0 =C2=A0 constant IDIGNORE=C2=A0 =C2=A0=3D=C2=A0 5;<br>
=C2=A0 =C2=A0 constant IDNO=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D=C2=A0 7;<br>
=C2=A0 =C2=A0 constant IDOK=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D=C2=A0 1;<br>
=C2=A0 =C2=A0 constant IDRETRY=C2=A0 =C2=A0 =3D=C2=A0 4;<br>
=C2=A0 =C2=A0 constant IDTRYAGAIN =3D 10;<br>
=C2=A0 =C2=A0 constant IDYES=C2=A0 =C2=A0 =C2=A0 =3D=C2=A0 6;<br>
<br>
<br>
=C2=A0 =C2=A0 # Note: the following two subs have to be embedded<br>
<br>
=C2=A0 =C2=A0 sub MessageBoxW( HANDLE, LPWCTSTR, LPWCTSTR, UINT ) is <br>
native(&#39;user32&#39;) returns INT { * };<br>
<br>
=C2=A0 =C2=A0 sub to-c-str( Str $str ) returns CArray[WCHAR]=C2=A0 {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0my @str :=3D CArray[WCHAR].new;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0for ( $str.comb ).kv -&gt; $i, $char { @str[$i] =
=3D $char.ord; }<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0@str[ $str.chars ] =3D 0;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0@str;<br>
=C2=A0 =C2=A0 }<br>
<br>
<br>
=C2=A0 =C2=A0 if=C2=A0 =C2=A0 =C2=A0$Icons eq &quot;Exclamation&quot;=C2=A0=
 { $IconInt =3D MB_ICONEXCLAMATION; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Warning&quot;=C2=A0 =C2=A0 =C2=A0=
 { $IconInt =3D MB_ICONWARNING; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Information&quot;=C2=A0 { $IconIn=
t =3D MB_ICONINFORMATION; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Asterisk&quot;=C2=A0 =C2=A0 =C2=
=A0{ $IconInt =3D MB_ICONASTERISK; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Question&quot;=C2=A0 =C2=A0 =C2=
=A0{ $IconInt =3D MB_ICONQUESTION; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Stop&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0{ $IconInt =3D MB_ICONSTOP; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Error&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 { $IconInt =3D MB_ICONERROR; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Icons eq &quot;Hand&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0{ $IconInt =3D MB_ICONHAND; }<br>
<br>
=C2=A0 =C2=A0 if=C2=A0 =C2=A0 =C2=A0$Buttons eq &quot;AbortRetryIgnore&quot=
;=C2=A0 =C2=A0 =C2=A0 =C2=A0{ $ButtonInt =3D <br>
MB_ABORTRETRYIGNORE; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;CancelTryAgainContinue&quot; { =
$ButtonInt =3D <br>
MB_CANCELTRYCONTINUE; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;Help&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{ $ButtonInt =3D MB_HELP; }=
<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;Ok&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{ $ButtonInt =3D MB_=
OK; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;OkCancel&quot;=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{ $ButtonInt =3D <br>
MB_OKCANCEL; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;RetryCancel&quot;=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 { $ButtonInt =3D <br>
MB_RETRYCANCEL; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;YesNo&quot;=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 { $ButtonInt =3D MB_YESNO; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $Buttons eq &quot;YesNoCancel&quot;=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 { $ButtonInt =3D <br>
MB_YESNOCANCEL; }<br>
<br>
=C2=A0 =C2=A0 $UINT =3D $IconInt +| $ButtonInt;=C2=A0 =C2=A0# Bitwise OR th=
em together<br>
<br>
=C2=A0 =C2=A0 $RtnInt =3D MessageBoxW( my $handle, to-c-str( $MessageStr ),=
 <br>
to-c-str( $TitleStr ), $UINT );<br>
<br>
=C2=A0 =C2=A0 # say $RtnInt;<br>
=C2=A0 =C2=A0 if=C2=A0 =C2=A0 =C2=A0$RtnInt =3D=3D DABORT=C2=A0 =C2=A0 =C2=
=A0 { $RtnStr =3D &quot;Abort&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDCANCEL=C2=A0 =C2=A0 { $RtnStr =
=3D &quot;Cancel&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDCONTINUE=C2=A0 { $RtnStr =3D &qu=
ot;Continue&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDIGNORE=C2=A0 =C2=A0 { $RtnStr =
=3D &quot;Ignore&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDNO=C2=A0 =C2=A0 =C2=A0 =C2=A0 { =
$RtnStr =3D &quot;No&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDOK=C2=A0 =C2=A0 =C2=A0 =C2=A0 { =
$RtnStr =3D &quot;Ok&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDRETRY=C2=A0 =C2=A0 =C2=A0{ $RtnS=
tr =3D &quot;Retry&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDTRYAGAIN=C2=A0 { $RtnStr =3D &qu=
ot;Try Again&quot;; }<br>
=C2=A0 =C2=A0 elsif=C2=A0 $RtnInt =3D=3D IDYES=C2=A0 =C2=A0 =C2=A0 =C2=A0{ =
$RtnStr =3D &quot;Yes&quot;; }<br>
<br>
=C2=A0 =C2=A0 return $RtnStr;<br>
}<br>
<br>
<br>
sub WinMsg( Str $TitleStr, Str $MessageStr ) is export( :WinMsg )=C2=A0 {<b=
r>
<br>
#`{<br>
=C2=A0 =C2=A0 =C2=A0 Simple &quot;Ok&quot; pop up with no return value<br>
<br>
=C2=A0 =C2=A0 =C2=A0 Test one liner:<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 perl6 -e &quot;use lib &#39;.&#39;; use =
WinPopUps :WinPopUp, :WinMsg; <br>
WinMsg( &#39;Super Duper Title&#39;, &#39;What? You were expecting somethin=
g witty?&#39; );&quot;<br>
<br>
}<br>
<br>
=C2=A0 =C2=A0 WinPopUp( $TitleStr, $MessageStr, &quot;Information&quot;, &q=
uot;Ok&quot; );<br>
<br>
}<br>
&lt;/WinpopUps.pm6&gt;<br>
</blockquote></div></div>
</blockquote></div>

--0000000000008fa4cc059aaa42af--
0
wbiker
12/27/2019 7:15:24 AM
On 2019-12-26 23:15, WFB wrote:
> Hi Todd,
> I refactored your code a bit to make it a bit more readable IMHO. 
> Thinking on publish it on modules.raku.org <http://modules.raku.org> if 
> you are not interested to do so.

Hi Tom,

I am interested, but not quite yet.  There are three dependent modules I 
need to tweak to my liking first.

     This one (WinPopUps)
     WinMount (gives Linux style mount and dismount
               and label and UUID searches)
     WinReg   (read and set registry values)

I will post them here when I am ready for everyone to
scrutinize before putting on modules.

In your mods, what is the syntax to export the "enum" calls?

-T
0
perl6
12/27/2019 12:16:14 PM
On 2019-12-26 23:15, WFB wrote:
> Hi Todd,
> I refactored your code a bit to make it a bit more readable IMHO. 
> Thinking on publish it on modules.raku.org <http://modules.raku.org> if 
> you are not interested to do so.


Hi Bill,

I did not think I would like enum, but wound up liking
it anyway.

my win message is ready to go.  I changed the name
and added a lot of your ideas to it.

I will open a new thread call "My Win Modules" and
start posting them there.  Three more to go!

Thank you for the wonderful tips!

-T
0
perl6
12/30/2019 1:27:35 AM
Hi All,

My latest three modules.  two more in the works that use these:

WinReg.pm6
WinMessageBox
NativeConstants.pm6

WinReg.pm6 about killed me!

-T


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

#`{

    Utilities to operate on the Windows registry

    perl6 -I. -c WinReg.pm6

    Test one liner:
       perl6 -I. -e "use WinMount :GetLUA; say GetLUA();"
       perl6 -I. -e "use NativeConstants; use WinReg :WinReadRegKey; say 
WinReadRegKey( HKEY_LOCAL_MACHINE, 
Q[SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system], 
Q[EnableLUA], REG_DWORD, True ).base(16);"
       perl6 -I. -e "use NativeConstants; use WinReg :WinReadRegKey; say 
WinReadRegKey( HKEY_LOCAL_MACHINE, Q[SOFTWARE\Microsoft\Windows 
NT\CurrentVersion], Q[ProductName], REG_SZ,True );"

    References:
 
https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
 
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw
 
https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-key-security-and-access-rights
 
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryvalueexw
 
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey
 
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey

}

use NativeCall;
use NativeConstants;
use WinMessageBox :WinMsg;


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;
}


sub OpenKey( WinRegHives $Hive, Str $SubKey, $Debug ) {

#`{
     Open the key:
 
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regopenkeyexw
 
https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-key-security-and-access-rights
     C++
     LSTATUS RegOpenKeyExW(
        HKEY    hKey,          # Hive name (HKEY_LOCAL_MACHINE)
        LPCWSTR lpSubKey,      # path to the 
key(/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/System/EnableLUA)
        DWORD   ulOptions,     # 0
        REGSAM  samDesired,    # KEY_READ (0x20019), KEY_SET_VALUE (0x0002)
        PHKEY   phkResult      # A pointer to a variable that receives a 
handle to the opened key
     );
}

    my Str $SubName = &?ROUTINE.name;

    my int32 $Handle;
    my int32 $RtnCode = 0;

    my $lpSubKey      = to-c-str( $SubKey );

    my int32 $ulOptions  = 0;
    my int32 $lpData     = 0;
    my int32 $lpcbData   = 1024;  # In:  the maximum amount of bytes 
allowed in the return variable
                                  # Out: the value of the key
    my int32 $lpReserved = 0;


    if $Debug { say "$SubName"; }
    sub RegOpenKeyExW(        DWORD,              WCHARS,    DWORD, 
DWORD,    DWORD is rw) is native("Kernel32.dll") returns DWORD { * };
    $RtnCode = RegOpenKeyExW( HKEY_LOCAL_MACHINE, $lpSubKey, $ulOptions, 
KEY_READ, $Handle );

    if not $RtnCode == 0  || $Debug == True  {
       my $ErrStr ="ERROR: $SubName\n   Handle $Handle\n   RtnCode 
$RtnCode\n" ~
           "Unable to open $Hive" ~ Q[\] ~ $SubKey ~ "\n";
       say $ErrStr;
       WinMsg( "Open Error", $ErrStr );
    }

    return $Handle;
}



sub CloseKey( int32 $Handle, $Debug ) {

#`{
     Close the key
 
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regclosekey

     C++
     LSTATUS RegCloseKey(
        HKEY hKey    # handle to the open key to be closed.  See 
RegOpenKeyExW phkResult
     );
}

    my Str $SubName = &?ROUTINE.name;

    my int32 $RtnCode = 0;

    if $Debug { say "$SubName"; }
    sub RegCloseKey( DWORD ) is native("Kernel32.dll") returns DWORD { * };

    $RtnCode = RegCloseKey( $Handle );

    if not $RtnCode == 0  || $Debug == True {
       say "ERROR: $SubName\n   Handle $Handle\n   RtnCode $RtnCode\n";
    }

}



sub WinReadRegKey( WinRegHives $Hive, Str $SubKey, Str $KeyName, 
ValueNames $ValueName, Bool $Debug = False ) is export( :WinReadRegKey ) {

#`{

     Return "Any" value of $Hive\$SubKey\$KeyName

     For Example:
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
           "EnableLUA"=dword:00000000
     $Hive    = HKEY_LOCAL_MACHINE\SOFTWARE
     $SubKey  = Microsoft\Windows\CurrentVersion\Policies   # no leading 
or trailing slashes
     $KeyName = EnableLUA


     References:
        Raku's NativeCall
        https://docs.perl6.org/language/nativecall

        Win32 return codes:
 
https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-

     Read the key:
     use RegQueryValueExW if you know key and value name
 
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryvalueexw
     C++
     LSTATUS RegQueryValueExW(
        HKEY    hKey,          # Hive handle from OpenKey
        LPCWSTR lpValueName,   # key name (EnableLUA)
        LPDWORD lpReserved,    # give it "int32" without the quotes to 
give it a NULL
        LPDWORD lpType,        # Registry Value Type (REG_DWORD which is 
32 bit)
        LPBYTE  lpData,        # Pointer to the return value
        LPDWORD lpcbData       # number of bytes in the return value
     );


}

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

    my int32 $Handle;
    my       $RtnCode;
    my Any   $KeyValue;

    my $lpSubKey    = to-c-str( $SubKey );  # 
SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
    my $lpValueName = to-c-str( $KeyName ); # EnableLUA

    my int32 $ulOptions  = 0;
#   my int32 $lpData; #     = 1024;
    my BYTES $lpData = CArray[BYTE].new( 0 xx 1024 );

    my int32 $lpcbData   = 1024;   # max size of returned data


    $Handle = OpenKey( HKEY_LOCAL_MACHINE, $SubKey, $Debug );

    if $Debug  { say "$SubName"; }
    sub RegQueryValueExW( DWORD, WCHARS, DWORD, DWORD, CArray[BYTE] is 
rw, DWORD is rw ) is native( "Kernel32.dll" ) is symbol( 
"RegQueryValueExW" ) returns DWORD { * };
    $RtnCode = RegQueryValueExW( $Handle, $lpValueName, 0, 0, $lpData, 
$lpcbData );

    if $Debug  { say "$SubName: data received, byte count $lpcbData"; }

    if not $RtnCode == 0  {
       say "ERROR: $SubName\n   Handle $Handle\n   RtnCode $RtnCode, 
0x$RtnCode.base(16)  " ~
        "\(2 KeyNotFound; 6 handle; 87 Invalid Parameter; 234 More 
data\)\n" ~
       "   lpcbData data length $lpcbData\n";
    }

    CloseKey( $Handle, $Debug );

    if $RtnCode == 0  {

       if $ValueName eq REG_SZ                        ||
          $ValueName eq REG_EXPAND_SZ                 ||
          $ValueName eq REG_LINK                      ||
          $ValueName eq REG_LINK                      ||
          $ValueName eq REG_MULTI_SZ                  ||
          $ValueName eq REG_RESOURCE_LIST             ||
          $ValueName eq REG_FULL_RESOURCE_DESCRIPTOR  ||
          $ValueName eq REG_RESOURCE_REQUIREMENTS_LIST   {
             loop (my $Index=0; $Index < $lpcbData - 2 ; $Index += 2) {
                $KeyValue ~= chr( $lpData[ $Index ] );
             }

          } else {
             # say "lpData = $lpData";
             loop (my $Index = 0; $Index < $lpcbData; $Index += 1 ) {
                my BYTE  $x = $lpData[ $Index ]; # say $x.base(16);
                my int32 $y = $x +| 0x0000;      # say $y.base(16);
                $KeyValue += ( $y +< ( $Index * 8 ) );
                # say "KeyValue = $KeyValue   $KeyValue.base(16)\n";;
          }
       }

    } else {
       $KeyValue = "ERROR";
       my $ErrStr ="ERROR: $SubName\n   Handle $Handle\n   RtnCode 
$RtnCode\n" ~
           "Unable to open $Hive" ~ Q[\] ~ $SubKey ~ Q[\] ~ $KeyName ~ 
Q[::] ~ $ValueName ~ "\n";
       say $ErrStr;
       WinMsg( "Open Error", $ErrStr );

    }

    return $KeyValue;
}
</WinReg.pm6>




<WinMessageBox>
# unit module WinMessageBox;
# MessageBox.pm6

#`{

     This Module provides access to Windows "user32" MessageBox function and
     give a WinMsg to substitute for Windows Professional's msg.exe 
program, without
     the networking.

     This module is not able to retrieve information from the user other 
than the buttons

        Test one liners:
         perl6 -e "use lib '.'; use WinMessageBox :MessageBox; say 
MessageBox( 'Some Title', 'Something Cleaver', MB_ICONINFORMATION, MB_OK 
);"
         perl6 -e "use lib '.'; use WinMessageBox :MessageBox; say 
MessageBox( 'Some Title', 'Something Cleaver', MB_ICONQUESTION, 
MB_YESNOCANCEL );
         perl6 -e "use lib '.'; use WinMessageBox :MessageBox; say 
MessageBox( 'Some Title', 'Something Cleaver', MB_ICONERROR, 
MB_CANCELTRYCONTINUE );"

         perl6 -e "use lib '.'; use WinMessageBox :WinMsg;     say 
WinMsg(     'Some Title', 'Something Cleaver' );"


       References:
 
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox
 
https://stackoverflow.com/questions/59105696/how-can-i-create-pop-up-windows-for-perl6-in-windows
          https://docs.perl6.org/language/nativecall
}

use NativeCall;
use NativeConstants;


enum Icons (
    MB_ICONEXCLAMATION   => 0x00000030,
    MB_ICONWARNING       => 0x00000030,
    MB_ICONINFORMATION   => 0x00000040,
    MB_ICONASTERISK      => 0x00000040,
    MB_ICONQUESTION      => 0x00000020,
    MB_ICONSTOP          => 0x00000010,
    MB_ICONERROR         => 0x00000010,
    MB_ICONHAND          => 0x00000010
);

enum Buttons (
    MB_ABORTRETRYIGNORE  => 0x00000002,
    MB_CANCELTRYCONTINUE => 0x00000006,
    MB_HELP              => 0x00004000,
    MB_OK                => 0x00000000,
    MB_OKCANCEL          => 0x00000001,
    MB_RETRYCANCEL       => 0x00000005,
    MB_YESNO             => 0x00000004,
    MB_YESNOCANCEL       => 0x00000003
);

enum MessageBoxReturn (
    ABORT     =>  3,
    CANCEL   =>  2,
    CONTINUE => 11,
    IGNORE   =>  5,
    NO       =>  7,
    OK       =>  1,
    RETRY    =>  4,
    TRYAGAIN => 10,
    YES      =>  6
);


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


sub MessageBox(
    Str $Title,
    Str $Message,
    Icons $Icon = Icons::MB_ICONINFORMATION,
    Buttons $Button = Buttons::MB_OK
)
    returns MessageBoxReturn is export( :MessageBox )
{

#`{
     Pop up a message box to the user.
     Windows only.
     Return what button was pressed

     See top for test one liners
}

    my Str $SubName = &?ROUTINE.name;
    my Str $OS      = $*KERNEL.name;

    if not $OS eq "win32" {
       say "Sorry, $SubName only work in Windows.";
       exit;
    }

    my $lpText    = CArray[uint16].new( $Message.encode.list ); 
$lpText[$lpText.elems]       = 0;
    my $lpCaption = CArray[uint16].new( $Title.encode.list ); 
$lpCaption[$lpCaption.elems] = 0;
    my $uType     = $Icon +| $Button;   # bitwise OR them together

    return MessageBoxReturn( MessageBoxW( my $Handle, $lpText, 
$lpCaption, $uType ));
}


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

#`{
     Simple "Ok" pop up with no return value.  Thjis as a subsitute for 
Windows `msg.exe` program
     that only runs in the Professinal version and without the netowrking.

     See top for test one liners
}

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

    return  MessageBox( $TitleStr, $MessageStr, MB_ICONINFORMATION, MB_OK );
}
</WinMessageBox>



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

#`{

     Constants used across Windows libraries that use Native Call

     Reference to types and values: 
http://dsource.org/projects/tango/ticket/820
 
https://docs.microsoft.com/en-us/windows/win32/sysinfo/registry-key-security-and-access-rights
 
https://docs.microsoft.com/en-us/windows/win32/intl/language-identifiers
 
https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-
     https://stackoverflow.com/questions/321413/lpcstr-lpctstr-and-lptstr
 
https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types
 
https://docs.microsoft.com/en-us/windows/win32/sysinfo/structure-of-the-registry

     perl6 -I. -c NativeConstants.pm6

     Test one liner:
        perl6 -I. -e "use NativeConstants; say 
FORMAT_MESSAGE_ALLOCATE_BUFFER.base(16);"

}


use NativeCall;

constant BYTE     := uint8;
constant WCHAR    := uint16;
constant DWORD    := int32;
constant REGSAM   := int32;
constant WCHARS   := CArray[WCHAR];
constant BYTES    := CArray[BYTE];
constant CPOINTER := int32;

constant INT      = int32;
constant UINT     = uint32;
constant HANDLE   = Pointer[void];
constant LPWCTSTR = CArray[WCHAR];

constant FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100;
constant FORMAT_MESSAGE_FROM_SYSTEM     = 0x00001000;
constant FORMAT_MESSAGE_IGNORE_INSERTS  = 0x00000200;

constant KEY_QUERY_VALUE   = 1;
constant ERROR_SUCCESS     = 0; # Win-Api  0 = success

constant KEY_READ      = 0x20019;
constant KEY_SET_VALUE = 0x0002;


enum WinRegHives (
    HKEY_CLASSES_ROOT     => 0x80000000;
    HKEY_CURRENT_USER     => 0x80000001;
    HKEY_LOCAL_MACHINE    => 0x80000002;
    HKEY_USERS            => 0x80000003;
    HKEY_PERFORMANCE_DATA => 0x80000004;
    HKEY_CURRENT_CONFIG   => 0x80000005;
    HKEY_DYN_DATA         => 0x80000006;
);

enum ValueNames (
    REG_NONE                       => 0;   # No value type
    REG_SZ                         => 1;   # Unicode nul terminated string
    REG_EXPAND_SZ                  => 2;   # Unicode nul terminated 
string = (with environment variable references)
    REG_BINARY                     => 3;   # Free form binary
    REG_DWORD                      => 4;   # 32-bit number
    REG_DWORD_LITTLE_ENDIAN        => 4;   # 32-bit number = (same as 
REG_DWORD)
    REG_DWORD_BIG_ENDIAN           => 5;   # 32-bit number
    REG_LINK                       => 6;   # Symbolic Link = (unicode)
    REG_MULTI_SZ                   => 7;   # Multiple Unicode strings
    REG_RESOURCE_LIST              => 8;   # Resource list in the 
resource map
    REG_FULL_RESOURCE_DESCRIPTOR   => 9;   # Resource list in the 
hardware description
    REG_RESOURCE_REQUIREMENTS_LIST => 10;
    REG_QWORD                      => 11;  # 64-bit number
    REG_QWORD_LITTLE_ENDIAN        => 11;  # same as REG_QWORD
);
</NativeConstants.pm6>
0
perl6
1/1/2020 7:02:23 AM
Reply: