Problem with dcl_PictureBox_DrawRect

Started by Emiliano, April 21, 2012, 07:42:19 AM

Previous topic - Next topic

Emiliano

I can not understand ...

The following code works fine:

Code (autolisp) Select

 (dcl_PictureBox_DrawRect NomeApp_NomeForm_PictureBox1 (list (list 10 10 300 20.0 1)))

 

but if I use the following returns the error "invalid argument":
Code (autolisp) Select

 (setq LunghSettore 300)
 (setq CoordX 10)
 (setq CoordY 10)

 (dcl_PictureBox_DrawRect NomeApp_NomeForm_PictureBox1 (list (list CoordX CoordY LunghSettore 20.0 1)))


Can you help?
 

roy_043

#1
Check if NomeApp_NomeForm_PictureBox1 is the correct symbol name for the control.

Edit: changed control-name as per OP's request.

Emiliano

It has the correct name.
I forgot to change the code before returning in the forum.  :'(
I do not like to be mentioned the name of the application.
At this regard you wonder if you can, please change it in your answer.  :-[
I've corrected my post.

You have any idea why it does not work?

roy_043

Maybe you have not set up the OnPaint event for the picture box? Temp graphics disappear whenever Windows repaints the control. The picture box is repainted by Windows after the OnInitialize event of the form. Any temp graphics created in the OnInitialize function will be lost.

Code (autolisp) Select

(defun c:NomeApp ( / c:NomeApp_NomeForm_OnInitialize c:NomeApp_NomeForm_PictureBox1_OnPaint CoordX CoordY LunghSettore pictureIsDoneP)

  (defun c:NomeApp_NomeForm_OnInitialize ()
    (print "c:NomeApp_NomeForm_OnInitialize")
  )

  (defun c:NomeApp_NomeForm_PictureBox1_OnPaint (HasFocus /)
    (print "c:NomeApp_NomeForm_PictureBox1_OnPaint")
    (if pictureIsDoneP
      (print "Using stored picture")
      (progn
        (dcl_PictureBox_DrawRect NomeApp_NomeForm_PictureBox1 (list (list CoordX CoordY LunghSettore 20.0 1)))
        (dcl_PictureBox_StoreImage NomeApp_NomeForm_PictureBox1) ; Storing the image is a good idea for large images.
        (setq pictureIsDoneP T)
        (print "Picture painted and stored")
      )
    )
  )

  (setq LunghSettore 300)
  (setq CoordX 10)
  (setq CoordY 10)
  (command "_opendcl")
  (dcl_Project_Load "NomeApp" T)
  (dcl_Form_Show NomeApp_NomeForm)
)

roy_043


Emiliano

Thanks for the reply.
The problem was that the values ​​were real numbers: dcl_PictureBox_DrawRect accepts only integers :-(

Thanks for the advice very useful: (dcl_PictureBox_StoreImage NomeApp_NomeForm_PictureBox1)


Emiliano

I have another problem.
I use the function (dcl_PictureBox_Clear NomeApp_NomeForm_PictureBox1).

Before using this function I want to check if the form and then the PictureBox is already open, because otherwise it gives me error.
How can I do?

I tried with the event OnInitialize but this is started before the Modeless Form is open

Fred Tomke

Hi,

you can use (if NomeApp_NomeForm_PictureBox1 T) to test whether the control is already available or not.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

roy_043

#8
Quote from: Emiliano on April 23, 2012, 01:33:40 AM
The problem was that the values ​​were real numbers: dcl_PictureBox_DrawRect accepts only integers :-(

I don't think that was the problem. My test shows that integers are accepted. And in your first post you have said:

Quote from: Emiliano on April 21, 2012, 07:42:19 AM
The following code works fine:
Code (autolisp) Select

 (dcl_PictureBox_DrawRect NomeApp_NomeForm_PictureBox1 (list (list 10 10 300 20.0 1)))


This may however be version-dependent. I have use ODCL version 7.0.0.1.

Emiliano

#9
Quote from: Fred Tomke on April 23, 2012, 03:36:05 AM
Hi,

you can use (if NomeApp_NomeForm_PictureBox1 T) to test whether the control is already available or not.

Regards, Fred

I tried your code but it does not work.
I also tried using:

(if (= (NomeApp_NomeForm_PictureBox1) T)

both return

; Error: wrong function: <Name entità: 14e69d08>

Do you have any idea?

Emiliano

Quote from: roy_043 on April 23, 2012, 04:18:59 AM
Quote from: Emiliano on April 23, 2012, 01:33:40 AM
The problem was that the values ​​were real numbers: dcl_PictureBox_DrawRect accepts only integers :-(

I don't think that was the problem. My test shows that integers are accepted. And in your first post you have said:

Quote from: Emiliano on April 21, 2012, 07:42:19 AM
The following code works fine:
Code (autolisp) Select

 (dcl_PictureBox_DrawRect NomeApp_NomeForm_PictureBox1 (list (list 10 10 300 20.0 1)))


This may however be version-dependent. I have use ODCL version 7.0.0.1.

It is true but when I insert the values ​​stored as variables setq will not work if they are real values​​.
I use ODCL version 7.0.0.2.
However, somehow it works now.

roy_043

@ Emiliano:
I did not read your reply #5 properly, hence my strange reply #8.
You are right: dcl_PictureBox_DrawRect only accepts integers or "integers as reals" (e.g. 20.0).

Emiliano

Ok!
have any solution for my reply #9?

roy_043

#13
The principle of Fred's suggestion:

Code (autolisp) Select
(if NomeApp_NomeForm_PictureBox1 ; ename or nil depending on visibility of dialog
 (progn
   ; Do something with NomeApp_NomeForm_PictureBox1
 )
)


See attached files.

BTW: I don't understand the function dcl_PictureBox_StoreImage anymore. It does not seem to be necessary?

Edit: Name has been corrected.

Emiliano

Ok thanks,
now it works! ; D

dcl_PictureBox_StoreImage is necessary because, otherwise, if I reduce to AutoCAD icon, the PictureBox is canceled.