Jump to content

Alert box


paulmcz

Recommended Posts

On 4/3/2022 at 7:12 AM, BIGAL said:

My Bricscad V20 works fine about 1 second

 

(defun MsgBox (title options message time / 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)
)

(msgbox  "Pts on wall" 0 "Select COGO points" 1)

 

 

is possible to change Alert box text cloror ?
or do highlight ?

Link to comment
Share on other sites

Unfortunately not with the methods shown above.

 

It might be possible to recreate an alert box with DCL and include text colours and highlights - would take a little time and thought to do so - but then you'd be wanting to ask will it be worth the effort to make a custom alert box for the amount of use it gets?

 

Not something I have ever done though

  • Like 1
Link to comment
Share on other sites

By way of example of colours in a DCL, this will write the letter 'H' in front of a highlighted background. Can't work out another way just now to do it another way. Text can be any of 256 colours so can the background.

Essentially creates an image tile, colours in a portion of is an writes the text as a vector graphic - so for this letter 'H' there are 9 lines of code. Do the same for a simple highlighted word and lots of lines of code.

 

Note that the vector points are from top left down rather than the usual bottom left up. There is probably a smarter way to create the text, have a library of the letters and insert at a point... but that isn't for me today.

 

(defun c:VectorLetters ( / fo fname dcl_id Message1)
  (Defun MyA ( origin BgCol TxCol ImgTile / )
    (start_image ImgTile)
    (fill_image (- origin 1) 0 (+ origin 9) 12 BgCol) ;;x1 y1 x2 y2 colour
    ;;x1 y1 x2 y2 colour. Upside down? No decimals
    (vector_image (+ origin 0) 12 (+ origin 3)  0 TxCol)  (vector_image (+ origin 1) 12 (+ origin 4)  0 TxCol)
    (vector_image (+ origin 7) 12 (+ origin 5)  0 TxCol)  (vector_image (+ origin 6) 12 (+ origin 4)  0 TxCol)
    (vector_image (+ origin 3)  6 (+ origin 6)  6 TxCol)  (vector_image (+ origin 3)  7 (+ origin 6)  7 TxCol)
    (end_image)
  )

  (Defun MyE ( origin BgCol TxCol ImgTile / )
    (start_image ImgTile)
    (fill_image (- origin 1) 0 (+ origin 9) 12 BgCol) ;;x1 y1 x2 y2 colour
    ;;x1 y1 x2 y2 colour. Upside down? No decimals
    (vector_image (+ origin 0)  0 (+ origin 0) 12 TxCol)  (vector_image (+ origin 1)  0 (+ origin 1) 12 TxCol)
    (vector_image (+ origin 0)  0 (+ origin 7)  0 TxCol)  (vector_image (+ origin 0)  1 (+ origin 7)  1 TxCol)
    (vector_image (+ origin 0)  5 (+ origin 5)  5 TxCol)  (vector_image (+ origin 0)  6 (+ origin 5)  6 TxCol)
    (vector_image (+ origin 0) 12 (+ origin 7) 12 TxCol)  (vector_image (+ origin 0) 11 (+ origin 7) 11 TxCol)
    (end_image)
  )

  (Defun MyF ( origin BgCol TxCol ImgTile / )
    (start_image ImgTile)
    (fill_image (- origin 1) 0 (+ origin 9) 12 BgCol) ;;x1 y1 x2 y2 colour
    ;;x1 y1 x2 y2 colour. Upside down? No decimals
    (vector_image (+ origin 0)  0 (+ origin 0) 12 TxCol)  (vector_image (+ origin 1)  0 (+ origin 1) 12 TxCol)
    (vector_image (+ origin 0)  5 (+ origin 5)  5 TxCol)  (vector_image (+ origin 0)  6 (+ origin 5)  6 TxCol)
    (vector_image (+ origin 0)  0 (+ origin 7)  0 TxCol)  (vector_image (+ origin 0)  1 (+ origin 7)  1 TxCol)
    (end_image)
  )

  (Defun MyH ( origin BgCol TxCol ImgTile / ) ;;WIDTHS 8 HEIGHT 12
    (start_image ImgTile)
    (fill_image (- origin 1) 0 (+ origin 9) 12 BgCol) ;;x1 y1 x2 y2 colour
    ;;x1 y1 x2 y2 colour. Upside down? No decimals
    (vector_image (+ origin 0)  0 (+ origin 0) 12 TxCol)  (vector_image (+ origin 1)  0 (+ origin 1) 12 TxCol)
    (vector_image (+ origin 0)  5 (+ origin 7)  5 TxCol)  (vector_image (+ origin 0)  6 (+ origin 7)  6 TxCol)
    (vector_image (+ origin 6)  0 (+ origin 6) 12 TxCol)  (vector_image (+ origin 7)  0 (+ origin 7) 12 TxCol)
    (end_image)
  )

  (Defun MyI ( origin BgCol TxCol ImgTile / ) ;;WIDTHS 8 HEIGHT 12
    (start_image ImgTile)
    (fill_image (- origin 1) 0 (+ origin 9) 12 BgCol) ;;x1 y1 x2 y2 colour
    ;;x1 y1 x2 y2 colour. Upside down? No decimals
    (vector_image (+ origin 2)  0 (+ origin 2) 12 TxCol)  (vector_image (+ origin 3)  0 (+ origin 3) 12 TxCol)
    (vector_image (+ origin 0)  0 (+ origin 5)  0 TxCol)  (vector_image (+ origin 0)  1 (+ origin 5)  1 TxCol)
    (vector_image (+ origin 0) 11 (+ origin 5) 11 TxCol)  (vector_image (+ origin 0) 12 (+ origin 5) 12 TxCol)
    (end_image)
  )

  (Defun MyO ( origin BgCol TxCol ImgTile / ) ;;WIDTHS 8 HEIGHT 12
    (start_image ImgTile)
    (fill_image (- origin 1) 0 (+ origin 9) 12 BgCol) ;;x1 y1 x2 y2 colour
    ;;x1 y1 x2 y2 colour. Upside down? No decimals
    (vector_image (+ origin 0)  2 (+ origin 0) 10 TxCol)  (vector_image (+ origin 1)  2 (+ origin 1) 10 TxCol)
    (vector_image (+ origin 6)  2 (+ origin 6) 10 TxCol)  (vector_image (+ origin 7)  2 (+ origin 7) 10 TxCol)
    (vector_image (+ origin 2)  0 (+ origin 5)  0 TxCol)  (vector_image (+ origin 1)  1 (+ origin 6)  1 TxCol)
    (vector_image (+ origin 1) 11 (+ origin 6) 11 TxCol)  (vector_image (+ origin 2) 12 (+ origin 5) 12 TxCol)

    (vector_image (+ origin 2) 10 (+ origin 2) 10 TxCol)  (vector_image (+ origin 2)  2 (+ origin 2)  2 TxCol)
    (vector_image (+ origin 5) 10 (+ origin 5) 10 TxCol)  (vector_image (+ origin 5)  2 (+ origin 5)  2 TxCol)

    (end_image)
  )

  (Defun MyU ( origin BgCol TxCol ImgTile / ) ;;WIDTHS 8 HEIGHT 12
    (start_image ImgTile)
    (fill_image (- origin 1) 0 (+ origin 9) 12 BgCol) ;;x1 y1 x2 y2 colour
    ;;x1 y1 x2 y2 colour. Upside down? No decimals
    (vector_image (+ origin 0)  0 (+ origin 0) 10 TxCol)  (vector_image (+ origin 1)  0 (+ origin 1) 10 TxCol)
    (vector_image (+ origin 6)  0 (+ origin 6) 10 TxCol)  (vector_image (+ origin 7)  0 (+ origin 7) 10 TxCol)
    (vector_image (+ origin 1) 11 (+ origin 6) 11 TxCol)  (vector_image (+ origin 2) 12 (+ origin 5) 12 TxCol)
    (vector_image (+ origin 2) 10 (+ origin 2) 10 TxCol)  (vector_image (+ origin 5) 10 (+ origin 5) 10 TxCol)

    (end_image)
  )




  (setq Alert_Type "Alert") ;Single Word alert type header. No special characters
  (setq Message1 "Message")    ;Many Words

;;;;;;;;;;;
;;Start DCL
  (setq fo (open (setq fname (vl-filename-mktemp "Alert" (getvar "TEMPPREFIX") ".dcl")) "w"))

;;Header
  (write-line "SelLays : dialog {" fo)
  (write-line "  key = \"Alert\";" fo)
  (write-line (strcat "  label = " Alert_type "; ") fo)
  (write-line "  spacer;" fo)

;;Message
  (write-line " :boxed_column { width = 50;" fo)
  (write-line "  :row {alignment = top;" fo)
  (write-line (strcat "     : text { key = \"UserText1\"; label = " Message1 "; width = 5; alignment = left;}") fo)
;1st image
  (write-line " : image { key = MyImg;  width = 0; height = 1; color = dialog_background;}" fo) ; create an image, colour 0
  (write-line "  }" fo) ; end row
  (write-line " }" fo) ; end boxed column

;2nd image
  (write-line " :boxed_column { width = 50;" fo)
  (write-line "  :row {alignment = top;" fo)
  (write-line " : image { key = AnotherImg;  width = 0; height = 1; color = dialog_background;}" fo) ; create an image, colour 0
  (write-line "  }" fo) ; end row
  (write-line " }" fo) ; end boxed column

;;Buttons
  (write-line " :boxed_column { width = 50;" fo)
  (write-line "   : button { key = \"accept\"; label = \"OK\"; is_default = true; is_cancel = true; fixed_width = true; width = 15; }" fo)
  (write-line " }" fo) ; end boxed column

  (write-line "}" fo)  ; end dialog
  (close fo)

  (setq dcl_id (load_dialog fname))
  (if (not (new_dialog "SelLays" dcl_id))
    (exit)
  )
;;End DCL definition

;;Image Texts;; x POSTION, BACGROUND COLOUR, TEXT COLOUR, IMAGE TILE
;;Define here which letter you want to use in order

  (MyA 0 256 7 "MyImg")
  (MyE 9 256 7 "MyImg")
  (MyI 18 256 7 "MyImg")
  (MyO 25 2 1 "MyImg")
  (MyU 34 9 7 "MyImg")
  (MyF 43 9 7 "MyImg")
  (MyH 52 9 7 "MyImg")

  (MyA 0 2 1 "AnotherImg")
  (MyH 9 3 5 "AnotherImg")
  (MyH 18 4 9 "AnotherImg")


;;Action Tiles
  (action_tile "OK"     "(done_dialog 1)")

;Run DCL
  (start_dialog)

  (unload_dialog dcl_id)
  (vl-file-delete fname)

  MyLayer
)

 

Edited by Steven P
Edited with updated code, something that I was curious enough to update
  • Like 1
Link to comment
Share on other sites

If the alert is a consistent message never changes, then on page 1 you will see where I mentioned using VSLIDE with Delay yes this works. The slide can be anything including background color.

  • Like 1
Link to comment
Share on other sites

  • 3 months later...
On 4/4/2022 at 3:53 PM, marko_ribar said:

Here is my latest one, but still the same or a little bit different issue - black background of cmd shell window - (startapp) function : it can't be avoided!!!

Also - it is VBScript method that is used in global...

[ EDIT : I think I've managed to avoid black cmd screen by using (dos_shellexe) function - you must have DosLib installed.../ EDIT ]

 

Hi there,

with the following, I managed to hide the cmd shell window and also the vbs file self deletes without locking the UI thread. For anyone further interested in the topic :)
 

(defun ms_msgbox ( com msg / title options time filename file WshShell)
  (setq title (strcat "Alert: " com) options (+ 4096 48) time 2)
  (setq filename (strcat (getvar 'tempprefix) "ms_msgxxx.vbs" ))
  (setq file (open filename "w"))
  (write-line (strcat "ret = WScript.CreateObject(\"WScript.Shell\").Popup(\"" msg "\", " (itoa time) ", \"" title "\", " (itoa options) ")" ) file)
  (write-line (strcat "Set oFso = CreateObject(\"Scripting.FileSystemObject\") : oFso.DeleteFile Wscript.ScriptFullName, True") file)
  (close file)
  (setq WshShell (vlax-create-object "WScript.Shell"))
  (vlax-invoke WshShell 'Run  (strcat "wscript.exe " filename ))
  (vlax-release-object WshShell)
  (princ)
)

 

Link to comment
Share on other sites

Here's an interesting version that uses the Express tool function (acet-ui-status):

;; This function delays processing of a lisp routine for the specified
;; length of time in seconds.
(defun delay (sec / elsp dt secs)
	(setq dt (getvar "DATE") secs (* 86400.0 (- dt (fix dt))))
	(while dt
		(setq dt (getvar "DATE") elsp (* 86400.0 (- dt (fix dt))))
		(if (or (< (- elsp secs) 0.0)(>= (- elsp secs) sec))(setq dt nil))
	)
   (princ)
)

;; (pjk-timemsg <Title> <Message> <duration in seconds>)
;; by PKENEWELL
;; This function uses the Express tool modeless display box
;; to display a message on the screen for a duration specified.
(defun pjk-Timemsg (title msg dur)

   ;; check to see if express tools are loaded.
   (if (not (acet-util-ver))
      (arxload "acetutil.arx"
         (progn
            (princ "\nExpress Tools Failed to Load. Program Aborted.")
            (exit)
         )
      )
   )

   (acet-ui-status msg title)
   (delay dur)
   (acet-ui-status)
   (princ)
)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...