While creating specific app i have need for
positioning forms with ref to ACAD window so
i created small wrapper for DCL_FORM_SHOW func.
(DCL_FORM_SHOW_L)
;;<|*NO|121|AL|NS:APP|
;; - POINTP
;; - Check to see if arg is valid point coordinate list. Return T or Nil.
(DEFUN POINTP (pt / l) ; *|>
(AND (= (TYPE pt) 'LIST) ; list
(SETQ l (VL-LIST-LENGTH pt)) ; not dotted
(VL-EVERY '(LAMBDA (x) x) (MAPCAR 'NUMBERP pt)) ; all numbers
(OR (= l 2) (= l 3)) ; 2 or 3 members
)
)
;;<|*NO|47|VLA|NS:APP|
;; - VLA-GET-APPWIN
;; - Return info of Acad Application Window (in pixels).
;; - Argument Pos values:
;; 0 = (WinWidth WinHeight)
;; values to retrieve Window Position: (xPos yPos)
;; 1=TL, 2=ML, 3=BL, 4=TC, 5=MC, 6=BC, 7=TR, 8=MR, 9=BR
;; 0 --w
;; | 1-----4-----7
;; h | | (GET-ACAD-WINDOW 7)
;; 2 5 8
;; | |
;; 3-----6-----9
(DEFUN GET-ACAD-WINDOW (Pos / fixF app w h x y) ; *|>
(COND ((MEMBER Pos '(0 1 2 3 4 5 6 7 8 9)) ; achk
(VL-LOAD-COM)
(DEFUN fixF (x)
(IF (< x 0)
0
x
)
)
(SETQ app (VLAX-GET-ACAD-OBJECT)
w (VLA-GET-WIDTH app)
h (VLA-GET-HEIGHT app)
x (fixF (VLA-GET-WINDOWLEFT app))
y (fixF (VLA-GET-WINDOWTOP app))
)
(COND ((= Pos 0) (LIST w h))
((= Pos 1) (LIST x y))
((= Pos 2) (LIST x (+ y (/ h 2))))
((= Pos 3) (LIST x (+ y h)))
((= Pos 4) (LIST (+ x (/ w 2)) y))
((= Pos 5) (LIST (+ x (/ w 2)) (+ y (/ h 2))))
((= Pos 6) (LIST (+ x (/ w 2)) (+ y h)))
((= Pos 7) (LIST (+ x w) y))
((= Pos 8) (LIST (+ x w) (+ y (/ h 2))))
((= Pos 9) (LIST (+ x w) (+ y h)))
(T NIL)
)
)
)
)
;;<|*NO|42|ODCL|NS:APP|
;; - call type 1 for positioning with reference of AutoCAD window
;; (DCL_FORM_SHOW_L dialogname 'P '(xPos yPos))
;; - call type 2 for centered inside AutoCAD window (must provide dlg size or approx)
;; (DCL_FORM_SHOW_L dialogname 'C '(Width Height))
(DEFUN DCL_FORM_SHOW_L (dlg mode pxl / ref) ; *|>
(COND ((AND (= (TYPE dlg) 'ENAME) (MEMBER mode (LIST 'P 'C)) (POINTP pxl)) ; achk
(IF (= mode 'P)
(SETQ ref (MAPCAR '+ (GET-ACAD-WINDOW 1) pxl))
(SETQ ref (GET-ACAD-WINDOW 5)
ref (LIST (- (CAR ref) (/ (CAR pxl) 2)) (- (CADR ref) (/ (CADR pxl) 2)))
)
)
(DCL_FORM_SHOW dlg (CAR ref) (CADR ref))
)
)
)
nothing. just feele like share