OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: copter on April 29, 2009, 12:26:44 PM

Title: Drawing Lines in a picture box on initialize doesnt work ?
Post by: copter on April 29, 2009, 12:26:44 PM
Hello

Is there a way to use the function dcl_PictureBox_DrawLine on initialize.
This function works fine well called from a button but returns nil when used on initialize.
How could I do ?

Thanks for your help

copter
Title: Re: Drawing Lines in a picture box on initialize doesnt work ?
Post by: Fred Tomke on April 29, 2009, 01:48:37 PM
I'm not familiar with drawing vectors on PictureBoxes but did you save the image within OnInitialize using StoreImage (http://www.opendcl.com/HelpFiles/index.php?page=Reference/Method/PictureBox/StoreImage.htm)?

Code (autolisp) Select
(dcl_PictureBox_StoreImage Unbenannt_Dialog1_Bild1)

Fred
Title: Re: Drawing Lines in a picture box on initialize doesnt work ?
Post by: copter on April 29, 2009, 02:10:49 PM
I tried. Same thing.
I attached an example.
Copter
Title: Re: Drawing Lines in a picture box on initialize doesnt work ?
Post by: velasquez on April 29, 2009, 02:15:41 PM
Hi 
Call dcl_PictureBox_DrawLine inside the property of OnPaint. 
(defun c:Project1_Form1_PictureBox1_OnPaint (nHasFocus /) 
   (dcl_PictureBox_DrawLine..... 

Attention this should be out of OnInitialize.
Title: Re: Drawing Lines in a picture box on initialize doesnt work ?
Post by: copter on April 29, 2009, 02:56:52 PM
I tried Onpaint (Sample is attached) but without success.
Title: Re: Drawing Lines in a picture box on initialize doesnt work ?
Post by: velasquez on April 29, 2009, 03:30:05 PM
Try now. 
You should have removed -> [Boolean] of the function OnPaint. 
Stop using dcl_PictureBox_DrawLine in OnInitialize. 
 
Why you this using vl-doc-ref?

Code (autolisp) Select

(dcl_project_load "d:/test")

;;;(defun c:Test_Form1_OnInitialize (/)
;;;  (dcl_PictureBox_DrawLine (vl-doc-ref 'test_Form1_PictureBox1) '((10 10 230 10 248)))
;;;)


(defun c:test_Form1_TextButton1_OnClicked (/)
  (dcl_PictureBox_DrawLine (vl-doc-ref 'test_Form1_PictureBox1) '((10 10 230 10 248)))
)

(defun c:test_Form1_PictureBox1_OnPaint (HasFocus /)
  (dcl_PictureBox_DrawLine (vl-doc-ref 'test_Form1_PictureBox1) '((10 10 230 10 248)))
)

(dcl_form_show (vl-doc-ref 'test_Form1))
Title: Re: Drawing Lines in a picture box on initialize doesnt work ?
Post by: Kerry on April 29, 2009, 07:05:35 PM
Quote from: velasquez on April 29, 2009, 03:30:05 PM
< .. >
 
Why you this using vl-doc-ref?

< .. >

he's likely to be compiling a  separate-namespace VLX ...
Title: Re: Drawing Lines in a picture box on initialize doesnt work ?
Post by: owenwengerd on April 29, 2009, 08:12:52 PM
This issue is due to the fact that the picture box Draw methods paint directly to the screen, so they do not work unless the picture box is visible. During OnInitialize, the controls are created, but not yet visible, so any direct painting fails. The suggested solution to use OnPaint is probably the best approach.
Title: Re: Drawing Lines in a picture box on initialize doesnt work ?
Post by: copter on April 29, 2009, 11:05:37 PM
Thanks everybody !

It works now !

The reason for vl-doc-ref is that I always compile in separate namespace my vlx files.

Copter.