OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: Oswald on April 16, 2010, 02:35:23 PM

Title: Commands in ControlBar
Post by: Oswald on April 16, 2010, 02:35:23 PM
Hi People ....

I make a ControlBar in a ODCL Test Project.

I put in ControlBar an PictureBox with Clicked Event.
In my c:TestProject_ControlBar1_PictureBox1_OnClicked I put this code:
Code (autolisp) Select

(c:TestProject_ControlBar1_PictureBox1_OnClicked (/)
   (command "line")
)

But It returns
Quoteerror: invalid AutoCAD command: nil

I don't know what is happening ...

Anyone have idea ?

Thanks ...
Title: Re: Commands in ControlBar
Post by: BazzaCAD on April 16, 2010, 03:01:12 PM
Select the PicBox, in the properties panel change the "Event Invoke" = 1-Asynchronous
Title: Re: Commands in ControlBar
Post by: Oswald on April 22, 2010, 05:45:04 AM
Quote from: BazzaCAD on April 16, 2010, 03:01:12 PM
Event Invoke" = 1-Asynchronous

Thanks Bazza.
It really works.
But I have in the same PicBox an OnMouseEntered and OnMouseMovedOff event.
And each mouse move on the PicBox put the function return in command line.

Have any command to avoid this command return ?

Bellow the code:
Code (autolisp) Select

(defun c:TestProject_frmTest_PictureBox1_OnMouseEntered (/)
(dcl_Control_SetPicture TestProject_frmTest_PictureBox1 174)
(princ "ttt")
)
(defun c:TestProject_frmTest_PictureBox1_OnMouseMovedOff (/)
  (dcl_Control_SetPicture TestProject_frmTest_PictureBox1 173)
)


Put T in command line

Thanks for all
Title: Re: Commands in ControlBar
Post by: Fred Tomke on April 22, 2010, 06:23:56 AM
Hi, Oswald,

add a (princ) in the end.

Code (autolisp) Select
(defun c:TestProject_frmTest_PictureBox1_OnMouseMovedOff (/) 
      (dcl_Control_SetPicture TestProject_frmTest_PictureBox1 173)
      (princ)
)


Fred
Title: Re: Commands in ControlBar
Post by: Oswald on April 22, 2010, 07:00:14 AM
Hi Fred,

Quote from: Fred Tomke on April 22, 2010, 06:23:56 AM
add a (princ) in the end.

I add (princ) but on each MouseOver/Out it makes new line print
Example:
Command:
Command:
Command:
Command:


Thanks ...
Title: Re: Commands in ControlBar
Post by: owenwengerd on April 22, 2010, 07:41:08 AM
You can set Event Invoke back to Synchronous, but execute your (command) calls from within a different function that you initiate by calling (dcl_SendString) or (dcl_DelyedInvoke).

By the way, if all goes according to plan, the next build of OpenDCL will not need the OnMouseEntered and OnMouseMovedOff handlers to switch the Keep Focus setting.
Title: Re: Commands in ControlBar
Post by: Oswald on April 22, 2010, 11:06:13 AM
Hi Owen,

Quote from: owenwengerd on April 22, 2010, 07:41:08 AM
You can set Event Invoke back to Synchronous, but execute your (command) calls from within a different function that you initiate by calling (dcl_SendString) or (dcl_DelyedInvoke).

Following your instructions I test using dcl_SendString and dcl_DelayedInvoke.

With DCL_SendString the command executes only after next command send by user.
The command was:
Code (autolisp) Select
(dcl_SendString "(line)")
Don't solve ...

Then I test DCL_DelayedInvoke ...
Code (autolisp) Select
(dcl_DelayedInvoke 100 "(line)")
Then I solve my problem. ...

Now it runs correctly ...

Thanks guys ..
Title: Re: Commands in ControlBar
Post by: owenwengerd on April 22, 2010, 11:54:15 AM
Quote from: Oswald on April 22, 2010, 11:06:13 AM
With DCL_SendString the command executes only after next command send by user.

You needed to add a '\n' at the end.
Title: Re: Commands in ControlBar
Post by: Oswald on April 22, 2010, 01:25:25 PM
Hi Owen,

Quote from: owenwengerd on April 22, 2010, 11:54:15 AM
You needed to add a '\n' at the end.

Really ... It works ...
I use thist:
Code (autolisp) Select
(dcl_SendString "(line)\n")
Then run ...

What's the best way ?
dcl_SendString or dcl_DelayedInvoke ?
Title: Re: Commands in ControlBar
Post by: owenwengerd on April 22, 2010, 01:35:36 PM
Quote from: Oswald on April 22, 2010, 01:25:25 PM
What's the best way ?
dcl_SendString or dcl_DelayedInvoke ?

Yes. ;)
Title: Re: Commands in ControlBar
Post by: Oswald on April 22, 2010, 02:03:20 PM
Hi Owen,
heheh

Quote from: owenwengerd on April 22, 2010, 01:35:36 PM
Quote from: Oswald on April 22, 2010, 01:25:25 PM
What's the best way ?
dcl_SendString or dcl_DelayedInvoke ?
Yes. ;)

Thanks for your answer
But what is the best method to use ?
SendString or DelayedInvoke ...
Or they're the same ?
Title: Re: Commands in ControlBar
Post by: BazzaCAD on April 22, 2010, 04:49:27 PM
I think he's suggesting that either one works just as good.
I'd use (dcl_SendString) so I don't have to deal with the delay, but that's just me... :)
Title: Re: Commands in ControlBar
Post by: owenwengerd on April 22, 2010, 06:05:44 PM
Quote from: Oswald on April 22, 2010, 02:03:20 PM
But what is the best method to use ?
SendString or DelayedInvoke ...
Or they're the same ?

You can use whichever you prefer; for your purposes they are identical.
Title: Re: Commands in ControlBar
Post by: Oswald on April 23, 2010, 04:36:42 AM
Quote from: owenwengerd on April 22, 2010, 06:05:44 PM
You can use whichever you prefer; for your purposes they are identical.
Quote from: BazzaCAD on April 22, 2010, 04:49:27 PM
I think he's suggesting that either one works just as good.
I'd use (dcl_SendString) so I don't have to deal with the delay, but that's just me... :)

Owen and Bazza ...

Thanks again ...