On my modeless form I have a few tools ( Option Lists, Frames, Check Boxes etc.)...
I made this procedure: when the CheckBox1 (cb1) is checked the OptionList1(OL1) appears, and when the CheckBox1 is unchecked the OptionList1 is hidden.
OnInitialize event I have set up the Long Value of the CheckBox1 on zero ( what means UNCHECKED), and (dcl_Control_SetVisible Proj_Form1_OptionList1 NIL), to have hidden the OptionList1, and UNCHECKED the CheckBox1.
Now, when I run my project, CheckBox1 is CHECKED, and OptionList1 VISIBLE, although these were been set up in ONINITIALIZE event of the form1.
What I have remarked, is that after form1 appears, my CheckBox1 is selected...like in picture below....
After that, I putted another CheckBox (Checkbox2) on my form1, and after project runs, Checkbox2 was selected (I think because was the last putted on the form..), and my settings from the ONINITIALIZE event of form1 were OK...After that, I have erased the last CheckBox (cb2), and CheckBox1 were again checked, how it should not be...
What I should do for overseen the selection, on ONINITIALIZE event? because I think this cause my problem...
Thanks.
Can you upload a simple form and lisp file that demonstrates the problem? Which version of OpenDCL are you using?
This is a simple example...if CheckBox is first in Z/tab order, goes wrong, and for example if Close button is first, everything is OK.
I`m using OpenDCL.Studio.ENU.6.0.0.23.msi
Thanks.
I cannot reproduce the problem in AutoCAD 2010 on Windows 7 x64. Can you test on another computer to see if the problem is reproducible on more than 1 computer?
I run the project on 3 different PC, all with Windows XP x 32, with AutoCAD 2007 and AutoCAD 2005...all with the same OpenDCL.Studio.ENU.6.0.0.23.msi alpha version.
The same result..
Hopefully someone else will test your sample and let us know whether they have the same problem.
Try removing the t reload option from this line:
(dcl_project_load "example" t)
(dcl_project_load "example")
Also, these lines don't look right:
(defun c:example_Form1_CheckBox1_OnClicked (Value /)
(setq cb_value (dcl_Control_GetValue example_Form1_CheckBox1)) ;;;; <---- you don't need this line, use the Value passed in by the OnClick function
(cond ((= cb_value 0)
((dcl_Control_SetVisible example_Form1_OptionList1 NIL)) ;;; <--- too many ()
)
((= cb_value 1)
((dcl_Control_SetVisible example_Form1_OptionList1 T)) ;;; <--- too many ()
)
)
)
Try this:
(defun c:example_Form1_CheckBox1_OnClicked (Value /)
(cond
((= Value 0)
(dcl_Control_SetVisible example_Form1_OptionList1 NIL)
)
((= Value 1)
(dcl_Control_SetVisible example_Form1_OptionList1 T)
)
);_ cond
);_ defun
Barry, are you able to reproduce the OP's problem?
BTW, this would be my version:
(defun c:example_Form1_CheckBox1_OnClicked (Value /)
(dcl_Control_SetVisible example_Form1_OptionList1 (= Value 1))
);_ defun
Quote from: owenwengerd on March 23, 2010, 10:26:23 AM
Barry, are you able to reproduce the OP's problem?
I didn't try it yet, since I'm on Win7 & Acad2010. I can try on an other XP machine wit hAcad2008 & 2010 late....
But since it sounded like an issue with reshowing the form & ONINITIALIZE even I thought it might be the reload flag...
Since the checkbox state is being set in OnInitialize, the initial value (and hence reloading) shouldn't matter one way or the other. In any case, I hope you get a chance to test it on both systems.
Thank you guys for your interest ... I tried all your alternatives, and the result is the same... the single way to resolve this is to put the checkbox in the bottom of the Z/Tab order list...As long as it works...it`s ok.
Thank you again !
Quote from: Iulian on March 24, 2010, 02:21:17 AMAs long as it works...it`s ok.
Hopefully we can track down the cause in case there's a bug hidden somewhere.
I am having similar problems with what seems like the oninitialize not working with check boxes. Thought I should mention I am using Windows 7 64 bit.
Mine is a modal form. I have a picture box at the front of the Z order and a few check boxes following. The first check box seems to ignore my oninitialize code. And as Iulian stated, if I put a button before the check box in the Z order, the check boxes initialize as expected. It seems the object before the check box needs to have an event or the work around has no effect as my picture box made no difference.
Can you upload a simple project that demonstrates the problem?
I have attached a zip file with an .odcl and a .lsp.
What I find is you have to run it and tick some check boxes, then close it. And do it all over again. After a few times it starts messing up. I can't figure out any certain way to make it mess up, it just eventually happens. Sometimes I can't seem to get it to mess up for a long time.
I did find that if you open the .lsp code in the vlide, and then reload it from there it seems to mess up right away. I have definitely noticed it more when I am working on the lisp. Hope that helps in some way.
In the sample project, your main function loads and shows the dialog before it defines the event handler functions. Try moving your event handler function definitions in front of the code that displays the dialog. Let me know whether that resolves your problem.
I changed the code as suggested and tried again. I am still seeing the problem. First time I ran it I checked box 2, pressed text button 2, & closed the dialog. Ran it again, and check box 1 was checked. I attached the revised lisp so you can confirm I did what you wanted.
I have a theory. Are you starting the command by typing it, then pressing the space bar? If so, try it again but press and hold the space bar, then wait to release it until the dialog is completely displayed. Now when you release it, the check box gets checked because it has focus and "space bar up" translates to toggling the check box state. Is that what you're seeing? You can test the theory by using the <Enter> key instead of the space bar when starting the command.
I've added code to ignore the space bar if it wasn't pressed while the check box control had input focus. This should fix the problem in the next build if I'm correct about the cause.
You are correct. Using enter seems to work fine... holding space until the dialog is visible seems to work fine.
I look forward to the next build ;D Thank you Owen.