String length

Started by velasquez, October 03, 2015, 04:46:58 AM

Previous topic - Next topic

velasquez

I had to use an invisible grid control to know the length of a string with dcl-Grid-CalcColumnWidth and pass the value to the width of a Label control in design mode. The width of the Label control will set the width of a Modal form en OnInitialize.
Does anyone know a better way to work with this?

Thanks,
Velasquez

roy_043

Am I understanding correctly that the width and caption of the label are ultimately fixed and you are doing this to get zero margins?

velasquez

Quote from: roy_043 on October 04, 2015, 10:58:28 AM
Am I understanding correctly that the width and caption of the label are ultimately fixed and you are doing this to get zero margins?

Hello Roy,
I need to create a modal form that works like AutoCAD Alert or as dcl-MessageBox in OpenDCL.

roy_043

In your first post when you say 'design mode', which I have interpreted as 'design time', you in fact mean 'at run time'.
It is an interesting problem and I think your solution is pretty clever, but I don't know a better one. I have checked dcl-Control-GetProperties and dcl-Control-Dump but they do not provide useful hidden information.

velasquez

#4
Quote from: roy_043 on October 05, 2015, 09:29:45 AM
In your first post when you say 'design mode', which I have interpreted as 'design time', you in fact mean 'at run time'.
It is an interesting problem and I think your solution is pretty clever, but I don't know a better one. I have checked dcl-Control-GetProperties and dcl-Control-Dump but they do not provide useful hidden information.
When you have talked at runtime.
Use the hidden grid was the best I have found.
Thanks Roy
Code (autolisp) Select

(defun c:test_form_OnInitialize (/ JoyWidth)
;;;Calculating the width of the Label control
  (setq JoyWidth (dcl-grid-calccolumnwidth test/form/Grid1 strText)) ;_ visible = false
;;; Apply the width of the form
  (dcl-control-setwidth test/form (+ JoyWidth 8))
;;; Apply the width in Label control
  (dcl-control-setwidth proj/form/label JoyWidth)
;;;
  (dcl-control-setcaption test/form/label strText)
) ;_ fim de defun

roy_043

Thank you for sharing the code.
If you set 'Use Right From Right' to 1 for the label its width should automatically change with the width of the form.

velasquez

Quote from: roy_043 on October 06, 2015, 01:12:40 AM
Thank you for sharing the code.
If you set 'Use Right From Right' to 1 for the label its width should automatically change with the width of the form.

Thank you Roy
I used your suggestion.