Hello,
when I close the form, the latest position is stored in the registry to make sure to reshow it on the latest position before closing.
(vl-registry-read (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "CPROFILE") "\\OpenDCL\\Dialogs\\<projectname/formname>") "TopLeftX")
It works fine on a workstation with a never changing screen configuration with 0,0 at the leftmost screen.
In former times - when I was young and unexperienced - I tried to make sure that the form will appear on a place within the visible monitor area. I couldn't image that form positions could be negative values.
In the meantime a customer told me that she cannot see the (modeless) dialog although it is open. A research for the reason ended up with the result in exactly the position-overriding in my former code: start the form at x=30 and y=30 when the last form position is obviously outside the visible monitor area. But infact x=30 and y=30 is outside for this customer. Less than 0 for x and more than 1980 for x is actually visible.
Is the any chance to retreive minx miny maxx maxy for each accessible screen and not only screensize?
I hope I was understandable.
With regards, Fred
Hi Fred,
I had the same problem with screen size / resolution changes. I use a function called during the initalisation of every form...
So in the OnInitialize function:
;; Make form visible if monitor size changes
(setq sz (dcl-GetScreenSize)
px (get_ODCL_pos "pm/edit" "TopLeftX")
py (get_ODCL_pos "pm/edit" "TopLeftY")
)
(if (or (< (car sz) px)(< (cadr sz) py))
(dcl-Form-Center (vl-doc-ref 'pm/edit))
)
;; ================================================================
;; Function: dpiSF
;; Purpose: Get DPI scaling factor for display adjustments (cached)
;; Parameters: None
;; Returns: Float - DPI scaling factor (1.0 for 96 DPI, proportional for others)
;; ================================================================
(defun dpiSF (/ res)
(or
;; Return cached value if already calculated
*dpiSF*
;; Otherwise calculate and cache the scaling factor
(and
;; Read current DPI setting from Windows registry
(setq res (vl-registry-read
"HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics"
"AppliedDPI"))
;; Calculate scaling factor: 96 DPI = 1.0 scale
(if (< 96 res)
;; For higher DPI, scale down (96/current_dpi)
(setq *dpiSF* (/ 96.0 res))
;; For 96 DPI or lower, use 1.0 (no scaling)
(setq *dpiSF* 1.0)
)
)
)
;; Return the scaling factor
*dpiSF*
)
;; ================================================================
;; Function: get_ODCL_pos
;; Purpose: Retrieve OpenDCL dialog position from registry with DPI scaling
;; Parameters: dlg - Dialog name/identifier string
;; pos - Position parameter name (e.g., "Left", "Top")
;; Returns: Scaled position value (integer) or default value 200
;; ================================================================
(defun get_ODCL_pos (dlg pos / val)
(if
;; Attempt to read position value from registry
(setq val
(vl-registry-read
(strcat "HKEY_CURRENT_USER\\"
(vlax-product-key)
"\\Profiles\\"
(getActiveProfile)
"\\OpenDCL\\Dialogs\\"
dlg)
pos
)
)
;; If registry value found, scale by DPI factor
(* (dpiSF) val)
;; Default position if registry read fails
200
)
)