dcl dialog box position and or repositioning

Discussion in 'AutoCAD' started by Bob Quinn, Jun 11, 2004.

  1. Bob Quinn

    Bob Quinn Guest

    Is it possible to force a position of a dialog box? I would like to record
    the position on exiting the dialog then force
    it to the same position the next time it is called so it does not pop up
    right in the middle of the screen. Thanks in advance : )
     
    Bob Quinn, Jun 11, 2004
    #1
  2. Bob Quinn

    Josh Guest

    the done_dialog function returns "A two-dimensional point list that is the
    (X,Y) location of the dialog box when the user exited it."
     
    Josh, Jun 11, 2004
    #2
  3. Bob Quinn

    ECCAD Guest

    Bob,
    Check out thread 'DCL Formatting' Jun09.

    Bob
     
    ECCAD, Jun 11, 2004
    #3
  4. Bob Quinn

    GaryDF Guest

    Yes you can...and I save this position to the windows registry.

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;; ARCH Display Position Function
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun ARCH:SETPOSXMODE (key /)
    (vl-registry-write
    "HKEY_CURRENT_USER\\Software\\Arch Program\\Controls\\Dialog\\PositionX"
    ""
    key
    )
    (setq ARCH#POSX
    (vl-registry-read
    "HKEY_CURRENT_USER\\Software\\Arch Program\\Controls\\Dialog\\PositionX"
    )
    )
    (princ)
    )
    (defun ARCH:SETPOSYMODE (key /)
    (vl-registry-write
    "HKEY_CURRENT_USER\\Software\\Arch Program\\Controls\\Dialog\\PositionY"
    ""
    key
    )
    (setq ARCH#POSY
    (vl-registry-read
    "HKEY_CURRENT_USER\\Software\\Arch Program\\Controls\\Dialog\\PositionY"
    )
    )
    (princ)
    )
    (defun ARCH:DIALOG_NEWLOCATION ()
    (setq ARCH#DIAP (done_dialog))
    (ARCH:SETPOSXMODE (rtos (car ARCH#DIAP) 2 0))
    (ARCH:SETPOSYMODE (rtos (cadr ARCH#DIAP) 2 0))
    (setq ARCH#DIAP (list (atoi ARCH#POSX) (atoi ARCH#POSY)))
    (princ)
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ARCH Dialog Setup
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun ARCH:DIALOG_POSITION (dialnam)
    (if (not (new_dialog
    dialnam
    DCL_ID
    ""
    (if ARCH#DIAP
    ARCH#DIAP
    '(-1 -1)
    )
    )
    )
    ((exit)
    (ARCH:DCL_ERROR)
    )
    )
    (princ)
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DCL Alert
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun ARCH:DCL_ERROR ()
    ;;(ARCH:ALERT-E "MsgBox \"Lisp Routine's DCL File not found.\nCheck and Verify
    Support Paths.\"")
    (alert
    "Lisp Routine's DCL File not found.\nCheck and Verify Support Paths."
    )
    (princ)
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; cancel Function
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun ARCH:CANCEL2 ()
    (ARCH:DIALOG_NEWLOCATION)
    (setq op nil)
    (done_dialog)
    (princ "\n*** ///////// Program CANCELLED ///////// ***")
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Accept Function
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;
    (defun ARCH:DO_ACT-DONE (key_pr)
    (ARCH:DIALOG_NEWLOCATION)
    (setq op key_pr)
    (done_dialog)
    (princ)
    )
    (defun ARCH:ACCEPT2 ()
    (ARCH:DIALOG_NEWLOCATION)
    (done_dialog)
    (princ)
    )



    Example of usage would be (ARCH:DIALOG_POSITION "ARCH_ANNO")
    Yes I know I am using global variables...in my case I have to....all of my 50
    plus
    dialog boxes make use of the vaiables.


    The enclosed example ARCH_WEB ....Place all of the files in your support path
    command name is WEB

    Gary
     
    GaryDF, Jun 11, 2004
    #4
  5. Bob Quinn

    BOBQ Guest

    thanks!! I'll admit I am a little confused about the registry use, is there
    no easier way?

    I'll try to dig in to it to see if I can figure out how to use it. Thanks
    again-bob.
     
    BOBQ, Jun 12, 2004
    #5
  6. Bob Quinn

    GaryDF Guest

    Yes there is, I was showing how to save the screen position, so that when you
    start a new drawing, or restart AutoCAD the screen position would be saved.

    From the help files:





    (new_dialog dlgname dcl_id [action [screen-pt]])

    Arguments

    dlgname

    A string that specifies the dialog box.

    dcl_id

    The DCL file identifier obtained by load_dialog.

    action

    A string that contains an AutoLISP expression to use as the default action. If
    you don't want to define a default action, specify an empty string (""). The
    action argument is required if you specify screen-pt.

    The default action is evaluated when the user picks an active tile that doesn't
    have an action or callback explicitly assigned to it by action_tile or in DCL.

    screen-pt

    A 2D point list that specifies the X,Y location of the dialog box on the screen.
    The point specifies the upper-left corner of the dialog box. If you pass the
    point as'(-1 -1), the dialog box is opened in the default position (the center of
    the AutoCAD drawing area).



    Try this example enclosed, it will position the dialog box at '(100 700) only. In
    other words the screen

    position is hard coded in. My way makes it user friendly, and it remembers that
    position for the next

    drawing or the next session of AutoCAD.



    Normal way: (if (not (new_dialog "square" DCL_ID)) (exit))

    Position way (if (not (new_dialog "square" DCL_ID "" '(100 700))) (exit))



    Example

    (defun C:SQR (/ DCL_ID DO_NEXT SIZE)
    (setq DCL_ID (load_dialog "SQUARE.DCL"))
    (if (not (new_dialog "square" DCL_ID "" '(100 700))) (exit))
    (start_image "image_sqr")
    (vector_image 10 10 10 50 -15)
    (vector_image 10 50 50 50 -15)
    (vector_image 50 50 50 10 -15)
    (vector_image 50 10 10 10 -15)
    (end_image)

    (action_tile "image_sqr" "(done_dialog 4)")
    (action_tile "edit_size" "(setq SIZE (distof $value 4))")

    (action_tile "accept" "(done_dialog 4)")
    (action_tile "cancel" "(done_dialog 0)")

    (setq DO_NEXT (start_dialog))
    (unload_dialog DCL_ID)

    (if (= DO_NEXT 4) (command "polygon" 4 pause "I" SIZE))
    );;defun SQUARE
    (prompt "\nType < SQR > to Execute!") (princ)




    // Draws a square vector image
    // on an image button tile

    dcl_settings : default_dcl_settings {audit_level=3;}

    square : dialog {label="The Square Program"; width=20; fixed_width=true;
    initial_focus="edit_size";
    :image_button {key="image_sqr"; color=graphics_background; width=10;
    fixed_width=true; aspect_ratio=1.0; allow_accept=true; alignment=centered;}
    :edit_box {label="Size:"; key="edit_size";}
    spacer;
    ok_cancel;
    spacer;
    }



    Hopes this helps.



    Gary
     
    GaryDF, Jun 12, 2004
    #6
  7. Bob Quinn

    ECCAD Guest

    GaryDF,
    Your attachment is not what you wanted to attach, I'm sure.

    Bob
     
    ECCAD, Jun 12, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.