Drawing Lines in a picture box on initialize doesnt work ?

Started by copter · 2009-04-29 19:26 UTC · 8 replies · SMF topic #736

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
I'm not familiar with drawing vectors on PictureBoxes but did you save the image within OnInitialize using {2}?

(dcl_PictureBox_StoreImage Unbenannt_Dialog1_Bild1)

Fred
I tried. Same thing.
I attached an example.
Copter
Attachments
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.
I tried Onpaint (Sample is attached) but without success.
Attachments
Try now. 
You should have removed -> of the function OnPaint. 
Stop using dcl_PictureBox_DrawLine in OnInitialize. 
 
Why you this using vl-doc-ref?


(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))
author=velasquez link=topic=736.msg3586#msg3586 date=1241044205 wrote:
< .. >
 
Why you this using vl-doc-ref?

< .. >


he's likely to be compiling a  separate-namespace VLX ...
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.
Thanks everybody !

It works now !

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

Copter.