Getting control captions (for translating) on tab pages

Started by copter, April 14, 2009, 04:50:09 AM

Previous topic - Next topic

copter

Hello everybody !
I need to translate the captions of all the controls of a form when initialize.
It works well, except on tab script control:
(foreach control (dcl_Form_GetControls Test_Form1)
  (setq props (dcl_control_getProperties control ))
  (if (member "Caption" props) (dcl_Control_SetCaption control (Translate (dcl_Control_GetCaption control )))
)
But dcl_Form_GetControls does not return the controls inside the pages of a tab control.
How can I get these controls ?

Thanks for your help !

Fred Tomke

Hi, have you already tried to invoke the GetControls method not only to the form object but also to the controls object? I know this method is only applicable to forms - however I would try it.
(dcl_Form_GetControls myProj_myForm_myTab)
Does this work? Should this work?

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Fred Tomke

Note: don't forget to translate the tab captions itself using the SetTabCaption method :)

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Slavko Ivanovic

Hi.
Hmm, very interesting.

I'm not 100% sure, but I'm afraid that you can not get that controls
in same meaner like U did with outside-tab controls.

Quote
Fred:
(dcl_Form_GetControls myProj_myForm_myTab)
Does this work? Should this work?
Fred, this don't work in my tests.


U probably must put some "manual" work in that.

Here is what I will do in that case:
- create single list with names of all controls in all tabs
- add another foreach for that list, with use of vl-symbol-value

here is my test.

Code (autolisp) Select

(DEFUN c:trtest ()
(DEFUN Translate (@oldc) (PRINC) (STRCAT @oldc "_translated"))
;; init
(DEFUN c:Test_proj1_Test_Form1_OnInitialize (/)
  ;; 1. foreach all outside tab (dcl_form_getcontrols)
  (FOREACH control (DCL_FORM_GETCONTROLS Test_proj1_Test_Form1)
   (SETQ props (DCL_CONTROL_GETPROPERTIES control))
   (IF (MEMBER "Caption" props)
    (DCL_CONTROL_SETCAPTION control (Translate (DCL_CONTROL_GETCAPTION control)))
   )
  )
  ;; 2. foreach all inside tab (manualy list)
  (SETQ list_of_controls_in_tabs (LIST "tabc1" "tabc2" "tabc3" "tabc4" "tabc5" "tabc6" "tabc7" "tabc8" "tabc9"))
  (FOREACH @cont list_of_controls_in_tabs
   (SETQ @cont (VL-SYMBOL-VALUE (READ (STRCAT "Test_proj1_Test_Form1_" @cont))))
   (DCL_CONTROL_SETCAPTION @cont (Translate (DCL_CONTROL_GETCAPTION @cont)))
  )
)
;; end init
;; load
(DCL_PROJECT_LOAD "Test_proj1" T)
(DCL_FORM_SHOW Test_proj1_Test_Form1)
)




u can download .odcl file.


***  siCAD Solutions for AutoCAD  ***
ArchiTools l ToolsPlus l LandTools l LBE

owenwengerd

The (dcl_Project_GetForms) function will return tab pages in the list of returned forms. There is no good way of knowing which ones belong to which tab control.  You could determine it empirically by looking at the controls contained by each form, and, assuming they use their default VarName, looking at the value of the VarName property of the first control. There really should be a (dcl_Control_GetChildForms) function, and I suggest that you add this as a feature request.
Owen Wengerd (Outside The Box) / ManuSoft

copter

Thanks Slavko for your help. I will made a list to do this.
And I'll made a new feature request, as Owen suggested, because this list will be quiet huge !
Copter
 


Fred Tomke

@Owen: maybe it will help in this case (for translating) if GetControls will return also all the controls which are placed on the tabs.

An example: I have a palette. There is only a tab on the form. All the other controls are placed on tabs. GetControls only return the tab control on the form.

Befehl: (dcl_Form_GetControls signothek_sc_signothek_fav)
(<Objektname: 1e03a480>)

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]