Option List Problem

Started by Iulian, October 17, 2009, 08:14:23 AM

Previous topic - Next topic

Iulian

Hi. I have a problem with the Option List tool. Like in the picture below (attached), when I click the first Option List button, I want to appear in the picture box below, "Picture 1". When I click the second Option List button, I want to appear "Picture 2" in the picture box below, and so on with the last Option List button. For this I used the procedure dcl_OptionList_GetCurSel for obtaining the current value of OptionButton1, and than, with IF function I made the connection between the current value and the corespondent picture. With TextButton1 I would like to see in a messagebox this value, assigned to OptList1CSel  . What I can do?
Thanks.

owenwengerd

If you want to use the value of OptList1CSel in another function, then you need to make it a global variable by removing it from the local variable list of your c:aaa function. The GetCurSel method returns -1 if no options are selected, or the zero based index of the currently selected item, so your use of it is correct.
Owen Wengerd (Outside The Box) / ManuSoft

BazzaCAD

#2
Hi Iulian,
Good start, but you have a few issue.
1. Like Owen said use a global variable (but you wont need it per below).
2. Your C:aaa function will never get called. C:zzz will show the form & it will take focus, you'd have to run the aaa command at the command line, but can't because you have a modal dialog.
3. Be sure to use the "Evants" tab next to the "Properties" Tab

Here's an alternative solution for you:

Code (autolisp) Select

(command "opendcl")
(defun C:zzz ()
 (dcl_project_load "example")
 (dcl_form_show example_form1)
 (princ)
)

(defun c:example_Form1_OptionList1_OnSelChanged (ItemIndexOrCount Value /)
  (cond
    ((= ItemIndexOrCount 0)
      (dcl_Control_SetPicture example_Form1_PictureBox1 100)
    )
    ((= ItemIndexOrCount 1)
      (dcl_Control_SetPicture example_Form1_PictureBox1 101)
    )
    ((= ItemIndexOrCount 2)
      (dcl_Control_SetPicture example_Form1_PictureBox1 102)
    )
  )
 (princ)
)

(defun c:example_Form1_GraphicButton1_OnClicked ( / OptList1CSel )
 (setq OptList1CSel (dcl_OptionList_GetCurSel example_Form1_OptionList1))
 (dcl_MessageBox (strcat "OptList1CSel value: " (itoa OptList1CSel)))
 (princ)
)



Hope this helps,
Barry
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

Iulian

Thank you very much for the code below and your information. Now it works.