Author Topic: DCL dialog change active window question  (Read 2846 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
DCL dialog change active window question
« on: September 24, 2008, 12:00:49 PM »
with DCL, what is the coding for when your dialog pops up and you make something else your active window, it won't close (as if you pressed ok)?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: DCL dialog change active window question
« Reply #1 on: September 24, 2008, 12:04:34 PM »
That sounds like normal behavior. The dialog should not close until the user closes it.
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.

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: DCL dialog change active window question
« Reply #2 on: September 24, 2008, 12:37:10 PM »
Sounds like you mean a Modal (floating) dialog.  Can't be done with DCL.

Do a search for OpenDCL
James Buzbee
Windows 8

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: DCL dialog change active window question
« Reply #3 on: September 24, 2008, 01:14:54 PM »
oops, should have proofed what i typed. i DON'T want it to close, but if i have it open and switch to a different window it will act as if i pressed ok. i want to prevent it from acting this way; i only want it to close if i click ok or hit escape. sorry guys.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: DCL dialog change active window question
« Reply #4 on: September 24, 2008, 01:40:10 PM »
Yep, that's Modal behavior.  DCL not going to provide that fuunctionality.
James Buzbee
Windows 8

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: DCL dialog change active window question
« Reply #5 on: September 24, 2008, 01:44:34 PM »
Yep, that's Modal behavior.  DCL not going to provide that fuunctionality.
but it's the only DCL dialog i've ever seen do this.
i'm 100% with you on how awesome odcl is, i'm working on learning it. however, this is for something very simple, 1 edit box to type in a single string and an ok button, that's it. i use it as a subroutine that i can just setq a value from it.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: DCL dialog change active window question
« Reply #6 on: September 24, 2008, 02:10:13 PM »
oops, should have proofed what i typed. i DON'T want it to close, but if i have it open and switch to a different window it will act as if i pressed ok. i want to prevent it from acting this way; i only want it to close if i click ok or hit escape. sorry guys.

tHEN THERE IS SOMETHING ABOUT THIS DIALOG THAT IS CLOSING IT.
Darn Caps!
Are you using an OK_Cancel button? Or a button you made?
Can you post the DCL & lisp code?
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.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: DCL dialog change active window question
« Reply #7 on: September 24, 2008, 03:58:22 PM »
oops, should have proofed what i typed. i DON'T want it to close, but if i have it open and switch to a different window it will act as if i pressed ok. i want to prevent it from acting this way; i only want it to close if i click ok or hit escape. sorry guys.

tHEN THERE IS SOMETHING ABOUT THIS DIALOG THAT IS CLOSING IT.
Darn Caps!
Are you using an OK_Cancel button? Or a button you made?
Can you post the DCL & lisp code?

lol, for a moment there, i really thought i had upset you.
here's the code, i don't know why i didn't just post it to begin with. i didn't create this, found it floating around here and just modified it a little.

Code: [Select]
(defun GetString-dlg (title str / dcl_id fn fo)
  (setq fn (vl-filename-mktemp "" "" ".dcl"))
  (setq fo (open fn "w"))
  (setq ValueStr (strcat "value = \"" str "\";"))
  (write-line (strcat "stringdlg : dialog {
              label = \"" title "\";") fo)
  (write-line ": edit_box {
              label = \"\";
              edit_width = 30;
              key = \"stringdlg\";
              is_default = true; " fo)
  (write-line ValueStr fo)
  (write-line "}" fo)
  (write-line ": row {
              alignment   = centered;
              fixed_width = true;
               : button {
               label      = \"OK\";
               key        = \"dcl_accept\";
               width      = 10;
               allow_accept = true;
             }
           }
         }" fo)
   (close fo)
   (setq dcl_id (load_dialog fn))
   (new_dialog "stringdlg" dcl_id)
   (action_tile "stringdlg" "(setq str $value)(done_dialog)")
   (start_dialog)
   (unload_dialog dcl_id)
   (vl-file-delete fn)
  str
 )
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: DCL dialog change active window question
« Reply #8 on: September 24, 2008, 04:16:55 PM »
Allow_accept - Instead of selecting an item from the list and then the OK
button, this allows you to select by double-clicking the list item.


Change allow_accept to is_default

Code: [Select]
(defun GetString-dlg (title str / dcl_id fn fo)
  (setq fn (vl-filename-mktemp "" "" ".dcl"))
  (setq fo (open fn "w"))
  (setq ValueStr (strcat "value = \"" str "\";"))
  (write-line (strcat "stringdlg : dialog {
              label = \"" title "\";") fo)
  (write-line ": edit_box {
              label = \"\";
              edit_width = 30;
              key = \"stringdlg\";" fo)
              ;is_default = true;
  (write-line ValueStr fo)
  (write-line "}" fo)
  (write-line ": row {
              alignment   = centered;
              fixed_width = true;
               : button {
               label      = \"OK\";
               key        = \"dcl_accept\";
               width      = 10;
               is_default = true;
             }
           }
         }" fo)
   (close fo)
   (setq dcl_id (load_dialog fn))
   (new_dialog "stringdlg" dcl_id)
   (action_tile "stringdlg" "(setq str $value)(done_dialog)")
   (start_dialog)
   (unload_dialog dcl_id)
   (vl-file-delete fn)
  str
 )
« Last Edit: September 24, 2008, 04:22:40 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: DCL dialog change active window question
« Reply #9 on: September 24, 2008, 04:19:52 PM »
Another version, no Title though.
Code: [Select]
;;; FUNCTION
;;;   Use ddedit box to edit a text string.
;;;
;;; ARGUMENTS
;;;  txt = the text string
;;;
;;; USAGE
;;;  text_edit
;;;
;;; PLATFORMS
;;; 2000+
;;;
;;; AUTHOR
;;; Charles Alan Butler
;;; ab2draft@TampaBay.rr.com
;;;
;;; VERSION
;;; 1.0 Oct. 06, 2004
(defun text_edit (txt / entlist ent)
  (if (entmake
        (list
          '(0 . "TEXT")
          (cons 10 '(0 0))
          (cons 40 1)
          (cons 7 (getvar "TEXTSTYLE"))
          (cons 1 txt) ; Text String
        )
      )
    (progn
      (setq ent (entlast))
      (command "._ddedit" ent "")
      (setq txt (cdr (assoc 1 (entget ent))))
      (entdel ent)
      txt
    )
  )
)

(defun c:test (/ newtext)
  (setq newtext (text_edit "This is a test string."))
)
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.