Combobox with "Style - Colors"

Started by Peter2, September 23, 2013, 11:17:48 AM

Previous topic - Next topic

Peter2

from the sample "misc.adcl" I used the combobox with the colors and wrote this function:

Code (autolisp) Select
(defun c:Verdrahtung_opt_verdrahtung_combox_farben_OnSelChanged (ItemIndexOrCount Value /)
    (if (not (dcl_Form_IsApplyEnabled Verdrahtung_opt_verdrahtung))
        (dcl_Form_SetApplyEnabled Verdrahtung_opt_verdrahtung T)
    )
    (setq freistellfarbe_temp Value)
)


a)
At first I tried to use "ItemIndexOrCount", and it worked fine for the standard colors (up to 9). Using one of the color dialogues just displayed the right value in the combobox (e.g. "Color 183"), but the return-value "ItemIndexOrCount" was always 0. What went wrong?

b)
Then I used the "Value" and get the names of the colors: red, green, color 183, ...
Using DXF-code (entmod) I need the numbers of the colors, and so I have to "convert" them from string to real: red -> 1, green -> 3.
That's not impossible, but working in a multi-language environment it could be a problem ...

Conclusion:
How do I get the color-number from the color-combobox?
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

roy_043

A. Nothing is going wrong. The index is not the ACI index but the list index.
B. I don't know a way around this.

Peter2

Quote from: roy_043 on September 23, 2013, 11:53:09 AM
A. Nothing is going wrong. The index is not the ACI index but the list index....
But when I select "Color 183" which is displayed in the list - why I do not get "184" as list index? I get 0 ...
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

Quote from: Peter2 on September 23, 2013, 12:05:03 PM
But when I select "Color 183" which is displayed in the list - why I do not get "184" as list index? I get 0 ...

Do I understand correctly that you first add Color 183 to the list, then select it? When I tried that, Color 183 was added at the beginning of the list, which is index 0. Therefore, 0 would be the correct list index in that case.

I think that GetItemData will return the ACI color value associated with a color combo box list item.
Owen Wengerd (Outside The Box) / ManuSoft

Peter2

Quote from: owenwengerd on September 23, 2013, 12:28:56 PM
Do I understand correctly that you first add Color 183 to the list, then select it? .....
No. I (my code) add nothing to the list. I have the "Combobox - Type 4 - Colors" which is created by ODCL. But I don't know how the list of colors is created - maybe the base-list has only the standard colors and all others are added while the user picks a color from the color-dialogues?
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

Quote from: Peter2 on September 23, 2013, 12:36:08 PM
But I don't know how the list of colors is created - maybe the base-list has only the standard colors and all others are added while the user picks a color from the color-dialogues?

Yes, and the list of added colors is stored in the current user profile.
Owen Wengerd (Outside The Box) / ManuSoft

Peter2

Quote from: owenwengerd on September 23, 2013, 12:28:56 PM
....When I tried that, Color 183 was added at the beginning of the list, which is index 0. Therefore, 0 would be the correct list index in that case....
The list consists always of "1 special color (index 0) plus following standard colors"?

Quote from: owenwengerd on September 23, 2013, 12:28:56 PM
I think that GetItemData will return the ACI color value associated with a color combo box list item.
I think I tried it already but I will try again on Wednesday.

Quote from: owenwengerd on September 23, 2013, 12:45:50 PM
Yes, and the list of added colors is stored in the current user profile.
Where? If I repeat the job and select some colors then I can see only the current selected color. It does not makes a history which stores formerly selected colors.
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

Owen Wengerd (Outside The Box) / ManuSoft

Peter2

Thank you. I will continue the day after tomorrow.
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

roy_043

Quote from: Peter2 on September 23, 2013, 01:02:19 PM
The list consists always of "1 special color (index 0) plus following standard colors"?
No. The special color 156 is added by Misc.lsp. The default list starts with "ByLayer".

Quote from: owenwengerd on September 23, 2013, 12:45:50 PM
Yes, and the list of added colors is stored in the current user profile.
This does not happen (at least not with BricsCAD).

owenwengerd

Owen Wengerd (Outside The Box) / ManuSoft

Peter2

Quote from: owenwengerd on September 23, 2013, 12:28:56 PM
I think that GetItemData will return the ACI color value associated with a color combo box list item.
Thank you. Confirmed - Solved.
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10