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
(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
(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.
See if this function retrieves the color value:
http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/ComboBox/GetItemData.htm (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/ComboBox/GetItemData.htm)
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
See if this helps:
http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/ComboBox/FindColor.htm (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/ComboBox/FindColor.htm)
Thanks again for your reply.
I hope it is useful to someone, with your help I wrote the following functions:
(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)
)
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 ....
Yes, this is the correct way to get the selected color value. If you want the displayed text, GetLBText should work.