Read and write color in Combobox

Started by Emiliano, March 26, 2012, 10:58:44 PM

Previous topic - Next topic

Emiliano

I just can not understand how to use the combobox with style "4 - Color".  :'(
I simply want to understand how to read and set a color.

- To read the color set, use the following code
Code (autolisp) Select

(setq col (dcl_ComboBox_GetTBText Applic_Form_ComboCol)))


However, in this way, the revenue of the color string in the language of AutoCAD (English, Italian, German, etc..)
how can I get the number of colors selected to avoid checking the language of AutoCAD?

- To set a color using the lisp code, I tried using
Code (autolisp) Select

(setq num_color "3") ;<--Green
(dcl_ComboBox_SetCurSel Applic_Form_ComboCol (+ (atoi num_color) 1))


This code works, until the list of the colors, is added, at the top the last color used.  :'(

I'm confused  ???
Can you help me?
Thanks in advance.

owenwengerd


Emiliano

Hi
Thanks for the reply.
Now I understand that finding the number of selected color in combox.

However the most difficult problem is to select, using the lisp code, a certain color.
I have a combobox that contains eg. the following list of colors:

Color71
Color73
Color96
Red
Yellow
Green <--Current Selection
Cian
Blue
Magent

How do I select the color "Blue" using Lisp code?
Thanks in advance


Emiliano

Thanks again for your reply.
I hope it is useful to someone, with your help I wrote the following functions:

Code (autolisp) Select

(defun TTComboGetColor (control / col)
  (setq col (dcl_ComboBox_GetItemData control (dcl_ComboBox_GetCurSel control)))
  col
)

(defun TTComboSetColor (control col / findel)
  (setq findel (dcl_ComboBox_FindColor control col))
  (if (= findel nil)
    (progn
      (dcl_ComboBox_AddColor control col)
      (setq findel (dcl_ComboBox_FindColor control col))
    )
  )
  (dcl_ComboBox_SetCurSel control findel)
)

Peter2

Is this solution still the current way to get the selected color in OpenDCL 8?

I looked around, found old examples with "GetTBText" (which seem to be outdated ...), tried with GetLBText and GetCurSel, and at the moment I'm a little bit confused ....
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

Yes, this is the correct way to get the selected color value. If you want the displayed text, GetLBText should work.