Popup
Function Syntax | (LM:popup <ttl> <msg> <bit>) |
Current Version | 1.1 |
Donate |
Arguments | ||
---|---|---|
Symbol | Type | Description |
ttl | String | Text to be displayed in the dialog title bar |
msg | String | Text content of the message box |
bit | Integer | Bit-coded integer indicating icon & button appearance |
Returns | ||
Type | Description | |
Integer | Integer indicating the button pressed to dismiss the message box |
Function Description
This function is essentially a wrapper for the Popup method of the Windows Script Host (WSH) Shell Object to display a customisable pop-up message box.
The title and content of the dialog are determined by the ttl and msg parameters respectively. The message box icon, number and type of buttons displayed, and format of the text are controlled by a combination of integer values supplied as the bit parameter. A reference for such values may be found below.
The integer value returned by the Popup method is dependent upon the button pressed to dismiss the message box. A reference for the return values may be found in the relevant table below.
;; Popup - Lee Mac ;; A wrapper for the WSH popup method to display a message box prompting the user. ;; ttl - [str] Text to be displayed in the pop-up title bar ;; msg - [str] Text content of the message box ;; bit - [int] Bit-coded integer indicating icon & button appearance ;; Returns: [int] Integer indicating the button pressed to exit (defun LM:popup ( ttl msg bit / wsh rtn ) (if (setq wsh (vlax-create-object "wscript.shell")) (progn (setq rtn (vl-catch-all-apply 'vlax-invoke-method (list wsh 'popup msg 0 ttl bit))) (vlax-release-object wsh) (if (not (vl-catch-all-error-p rtn)) rtn) ) ) )
Example Function Call
The following function call will display the dialog as shown in the graphic.
(LM:popup "Title Text" "This is a test message." (+ 2 48 4096))

The following information is referenced from the MSDN entry for the Popup method.
Reference for 'bit' Parameter
Buttons
Value | Description |
---|---|
0 | Display OK button |
1 | Display OK and Cancel buttons |
2 | Display Abort, Retry, and Ignore buttons. |
3 | Display Yes, No, and Cancel buttons. |
4 | Display Yes and No buttons. |
5 | Display Retry and Cancel buttons. |
6 | Display Cancel, Try Again, and Continue buttons. |
Icons
Value | Description |
---|---|
16 | Display Stop Mark icon. |
32 | Display Question Mark icon. |
48 | Display Exclamation Mark icon. |
64 | Display Information Mark icon. |
Other
Value | Description |
---|---|
256 | The second button is the default button. |
512 | The third button is the default button. |
4096 | The message box is a system modal message box and appears in a topmost window. |
524288 | The text is right-justified. |
1048576 | The message and content text display in right-to-left reading order. |
Return Values
The following table lists the integer value returned when the associated button is pressed to dismiss the message box.
Value | Description |
---|---|
1 | OK button |
2 | Cancel button |
3 | Abort button |
4 | Retry button |
5 | Ignore button |
6 | Yes button |
7 | No button |
10 | Try Again button |
11 | Continue button |