udfWshPopup
int udfWshPopup (int, str, str, int)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfWshPopup (intTimeout, strTitle, strText, intFlags)
objWShell = ObjectCreate ("WScript.Shell")
intResult = objWShell.popup(strText, intTimeout, strTitle, intFlags)
objWShell = 0
Return intResult
;..........................................................................................................................................
; This UDF "udfWshPopup" uses the shell object of the Windows Script Host to popup a message box with buttons, icons and auto timeout.
;
; Parameters:
; intTimeout ... Number of seconds before the message box automatically closes (returns -1 when closed).
; strTitle ..... Window title name of the message box.
; strText ...... Text message to display.
; intFlags ..... Integer value containing binary OR'ed (|) values to control the type of button options and icons displayed.
;
;                +-----STYLE-----------------------+-----ICONS-----------------+
;                | OK                = 0           | STOP       = 16           |
;                | OKCANCEL          = 1           | QUESTION   = 32           |
;                | ABORTRETRYIGNORE  = 2           | EXCLAIM    = 48           |
;                | YESNOCANCEL       = 3           | INFO       = 64           |
;                | YESNO             = 4           |                           |
;                | RETRYCANCEL       = 5           +----RETURN VALUES----------+
;                | CANCELTRYCONTINUE = 6           | IDOK       = 1            |
;                +-----BUTTONS---------------------+ IDCANCEL   = 2            |
;                | DEFAULTBUTTON1    = 0           | IDABORT    = 3            |
;                | DEFAULTBUTTON2    = 256         | IDRETRY    = 4            |
;                | DEFAULTBUTTON3    = 512         | IDIGNORE   = 5            |
;                | DEFAULTBUTTON4    = 768         | IDYES      = 6            |
;                +-----MODALITY--------------------+ IDNO       = 7            |
;                | APPLMODAL         = 0           | IDTRYAGAIN = 10           |
;                | SYSTEMMODAL       = 4096        | IDCONTINUE = 11           |
;                | TASKMODAL         = 8192        | TIMEOUT    = -1           |
;                +-----HELP------------------------+---------------------------+
;                | HELP              = 16384                                   |
;                | Add Help button. When the user clicks the Help button or    |
;                | presses F1, the system sends a WM_HELP message to the owner |
;                | window (needs windows message event hook to detect).        |
;                +---------------------------------+---------------------------+
;                | Combine flags with OR operator: Flags = 4|48|256|4096       |
;                +---------------------------------+---------------------------+
;
; Reference:
; http://technet.microsoft.com/en-us/library/ee156593.aspx
; http://technet.microsoft.com/en-us/query/ms645505
;
; (c)Detlev Dalitz.20111214.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test. Example script by IFICantBYTE, 2011-12-14, slightly modified.

; Create a big message text out of 30 lines with 100 chars per line.
strText = ""
For intLine = 1 To 30
   strText = strText : @LF : StrFixLeft (intLine, "0", 2) : ": " : StrFill ("0123456789", 100)
Next
; In this case we are eager to use the leading LineFeed.

While @TRUE
   ; Different examples showing some of the possible display options and the returned values from each at the end.
   intResult1 = udfWshPopup (5, "Test 1", "5 second timeout with STOP icon and OK button." : @LF : strText, 16)
   intResult2 = udfWshPopup (7, "Test 2", "7 second timeout with QUESTION MARK icon and OK and CANCEL buttons." : @LF : strText, 32 | 1)
   intResult3 = udfWshPopup (8, "Test 3", "8 second timeout with EXCLAMATION icon and ABORT RETRY IGNORE buttons. IGNORE has been made the DEFAULT option." : @LF : strText, 48 | 2 | 512)
   intResult4 = udfWshPopup (4, "Test 4", "4 second timeout with NO icon and just an OK button." : @LF : strText, 0)

   strResult = "Here is a list of the values returned by each previous test message" : @LF : "-1 is a timeout, other values depend on the button that was pushed:"
   strResult = strResult : @LF : @LF : intResult1 : @LF : intResult2 : @LF : intResult3 : @LF : intResult4
   udfWshPopup (0, "All test results", strResult, 64); Show the returned values from the above tests with no timeout.

   intYesNo = udfWshPopup (0, "Do you want to repeat the test?", "Do you want to repeat the test?" : @LF : "Press YES to do the examples again, NO to quit", 32 | 4)
   If intYesNo != 6 Then Break ; If anything other than 6 (YES) was returned, then break the loop.
EndWhile

:CANCEL
Exit