Drawing Lines in a picture box on initialize doesnt work ?

Started by copter, April 29, 2009, 12:26:44 PM

Previous topic - Next topic

copter

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

Fred Tomke

I'm not familiar with drawing vectors on PictureBoxes but did you save the image within OnInitialize using StoreImage?

Code (autolisp) Select
(dcl_PictureBox_StoreImage Unbenannt_Dialog1_Bild1)

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

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

copter


velasquez

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.

copter

I tried Onpaint (Sample is attached) but without success.

velasquez

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))

Kerry

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 ...
Perfection is not optional.
My other home is TheSwamp

owenwengerd

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.
Owen Wengerd (Outside The Box) / ManuSoft

copter

Thanks everybody !

It works now !

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

Copter.