Author Topic: Create a message box  (Read 15688 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Create a message box
« Reply #15 on: July 23, 2009, 10:41:12 AM »
Alan

Pretty sweet. Will it work for 2010 version?
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Create a message box
« Reply #16 on: July 23, 2009, 11:01:19 AM »
It should because it's just a DCL made on the Fly.

The advantage of this routine is that YOU can create some custom buttons.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Create a message box
« Reply #17 on: July 23, 2009, 11:41:04 AM »
Updated version:
Look for this in the code
Code: [Select]
 ;;  create the dcl with buttons
  ;;  List is (<button name> <return value>)
  ;;  ButCode value may be 0 through 15
Where you may define your buttons & return values.

<edit: Old Code Removed>
« Last Edit: July 24, 2009, 01:32:39 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Create a message box
« Reply #18 on: July 23, 2009, 03:18:21 PM »
Feature added to version 1.2  User defined buttons
Supply a list for ButCode in place of an interger.
Syntax: (MsgBox "Message Box Title" '(256 (("stop" 1)("go" 2)("quit" 0))) '("This is my message."))
Where 256 is a 'Second button is default' code & the following list is the button pairs in a list
"stop" is the button and 1 is the return value. You could also use nil in place of 256.
Code: [Select]
;;----------------------------------------------------------------------
;; MsgBox Ver 1.2   07.16.09
;; By  CAB @ TheSwamp.org
;; Description:  - Message Box with button options
;; Arguments: 3
;;   Title$ = Dialog Title
;;   MsgList = List of text strings, one per line
;;   ButCode = Button Code (add values)
;;     0 Display OK button only.
;;     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.
;;    16 Display Critical Message icon.  [ note icons not implemented yet ]
;;    32 Display Warning Query icon.
;;    48 Display Warning Message icon.
;;    64 Display Information Message icon.
;;     0 First button is default.
;;   256 Second button is default.
;;   512 Third button is default.
;;   768 Fourth button is default.;;
;; Syntax: (MsgBox "Message Box Title" 4 '("This is my message." "2nd Line of text."))
;; Button  Return Value
;;  OK         1
;;  Cancel     2  Escape/Cancel defaults to this
;;  Abort      3  Escape/Cancel defaults to this
;;  Retry      4
;;  Ignor      5
;;  Yes        6
;;  No         7
;;
;;  Note when Canceling the Box with the X out or the Escape Key, then  Cancel or Abort
;; will be used or the last button defined if they are not present. That is the code that
;;  will be returned.  For example the (Yes No) when canceled will return the No code
;;  because it was the last button defined and there were no Cancel or Abort buttons.
;|
This LISP takes the list of text strings and the button code to write a DCL file in the
folder where "ACAD.PAT" is found. The DCL file "MsgBox.dcl" is created and then called
to display the message box. The text strings should not exceed the displays height & width.
The button codes from the list above may be added to the icon code (not at this time) and
added to the default button code to get the desired results. The return values are hard
coded in list pairs but may be changed as desired.

Feature added to version 1.2  User defined buttons
Supply a list for ButCode in place of an interger.
Syntax: (MsgBox "Message Box Title" '(256 (("stop" 1)("go" 2)("quit" 0))) '("This is my message."))
Where 256 is a 'Second button is default' code & the following list is the button pairs in a list
"stop" is the button and 1 is the return value. You could also use nil in place of 256.
|;
;;------------------------------------------------------------------
  )

<edit: Old Code Removed>
« Last Edit: July 24, 2009, 01:32:09 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Create a message box
« Reply #19 on: July 23, 2009, 04:13:06 PM »
Works in version 2010

Just updated my routines for 2010. Question: can a pull down menu be added for 2010?
I can't get mine to come up.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Create a message box
« Reply #20 on: July 23, 2009, 04:37:24 PM »
Thanks Crank
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Crank

  • Water Moccasin
  • Posts: 1503
Re: Create a message box
« Reply #21 on: July 23, 2009, 04:37:43 PM »
...can a pull down menu be added for 2010?
Yes, there are several options possible: rightclick menu; menubar; ribbon or QAT. Please make another topic for this in 'CAD General'.

Now back on topic... :P
Vault Professional 2023     +     AEC Collection

VVA

  • Newt
  • Posts: 166
Re: Create a message box
« Reply #22 on: July 24, 2009, 02:33:31 AM »
My attempt to add the icons.
Icons and some functions taken from GetIcon.lsp, created by Terry Miller ( http://web2.airmail.net/terrycad )
Use Test1, Test2, Test3 and Test4 command

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Create a message box
« Reply #23 on: July 24, 2009, 01:30:34 PM »
Thanks Vladimir, 8-)

I reformatted the vector list removing the extra code and rewrote the Vector_Line function.
New version attached.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Create a message box
« Reply #24 on: July 24, 2009, 02:34:16 PM »
Works in version 2010:

Code: [Select]
(defun MsgBox2 (title buttons message time / return WshShell)
;;http://www.theswamp.org/index.php?topic=29537.0
  (setq WshShell (vlax-create-object "WScript.Shell"))
  (setq return (vlax-invoke
  WshShell
  'Popup
  message
  time
  title
  (itoa buttons)
)
  )
  (vlax-release-object WshShell)
  return
)

(defun MISC-KEY  ()
  (MsgBox " Arch Program : Info" 48 "
      PROGRAM Routines :
--------------------------------------------------------------------------------------------
      CALC\t\tWindows Calculator...
      CLIPBOARD\tWindows Clipboard Viewer...
      CONTROL\tWindows Control Panel...
      EXCEL\tWindows Excel...
      EXPL\t\tWindows Explorer...
      NOTEPAD\tWindows NotePad...
      POWERPOINT\tWindows Power Point..
      PRINTERS\tWindows Printers...
      WINWORD\tWindows WinWord...
      WORDPAD\tWindows WordPad...
   
      ALBUM\tACAD Album...
      AUTODC\tAutoLisp Code Breaker 
      CALU\t\tFoot-Inch Trig Calculator...
      CONVERTOR\tUnit Convertor...
      EDITPAD\tEditPad Editor...     
      FVIEWER\tFont Viewer...
      LLL\t\tMake List to File...
      LISPDOC\tAutoLisp Editor...
      LSPSURF\tAutoLisp Editor... 
      PFE32\tAutoLisp Editor...     
      RESHACKER\tProgram Code Breaker...
      SCRIPTPRO\tScript Pro...
      SLIDEMAN\tSlide Manager...
      VLIDEIT\tVisual Lisp...     
      " 4))
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Create a message box
« Reply #25 on: July 24, 2009, 03:27:16 PM »
Nice coding Alan 8-)
Speaking English as a French Frog

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Create a message box
« Reply #26 on: July 24, 2009, 04:40:32 PM »
Thanks Gile, Quite a complement considering the source. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ymg

  • Guest
Re: Create a message box
« Reply #27 on: July 03, 2014, 04:49:10 PM »
I know it is a very old thread, but with Patrice's routine I cannot get the
timer option to work.

I have this as a workaround, now the timer works, but I cannot have
the return value if you pressed one of the buttons.

Code: [Select]
;;;***************************************************************************;
;;; MsgBox by Patrick_35                                                      ;
;;;                                                                           ;
;;; Val options                                                               ;
;;; 0   vlax-vbOKOnly                                                         ;
;;; 1   vlax-vbOKCancel                                                       ;
;;; 2   vlax-vbAbortRetryIgnore                                               ;
;;; 3   vlax-vbYesNoCancel                                                    ;
;;; 4   vlax-vbYesNo                                                          ;
;;; 5   vlax-vbRetryCancel                                                    ;
;;; 16  vlax-vbKatakana                                                       ;
;;; 32  vlax-vbQuestion                                                       ;
;;; 48  vlax-vbExclamation                                                    ;
;;; 64  vlax-vbInformation                                                    ;
;;;                                                                           ;
;;; Modified so the timer works by ymg                                        ;
;;; However always returns 0, so cannot detect which button was pressed.      ;
;;;***************************************************************************;
 
(defun MsgBox (title options message time / rtn WshShell)
   (setq WshShell (vlax-create-object "WScript.Shell"))
    (vlax-invoke WshShell 'Run
(strcat "mshta.exe vbscript:close(CreateObject(\"WScript.Shell\").Popup(\""
  message "\"," (itoa time) ",\"" title "\"," (itoa options)"))"
         )
    )
   (vlax-release-object WshShell)
)
« Last Edit: July 03, 2014, 05:09:33 PM by ymg »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Create a message box
« Reply #28 on: July 03, 2014, 06:07:37 PM »
This works for me but the timer is off by a factor of 3.
value of 5 takes 15 seconds MOL.
Code: [Select]
(defun MsgBox (title buttons message time / return WshShell)
  (setq WshShell (vlax-create-object "WScript.Shell"))
  (setq    return    (vlax-invoke
          WshShell
          'Popup
          message
          time
          title
          (itoa buttons)
        )
  )
  (vlax-release-object WshShell)
  return
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ymg

  • Guest
Re: Create a message box
« Reply #29 on: July 03, 2014, 07:56:18 PM »
CAB,

Quote
This works for me but the timer is off by a factor of 3.

For me it simply hangs there with the hourglass cursor until I press OK.

Probably depends on version.

ymg