New OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: domenicomaria on April 27, 2019, 11:02:14 AM

Title: picturebox ONPAINT event
Post by: domenicomaria on April 27, 2019, 11:02:14 AM
I use a picture box
to show a linetype
using dcl-picturebox-drawsolidrect

it normally works

but NEVER works
the first time
when I show the form

If I put the function that shows the linetype
in the ONINITIALIZE defun
it executes that function
but it shows nothing

if i put
the same function
in the ONPAINT defun
IT LOCKS THE PC ! ! !

it works only
when i change the selection
in the list of linetypes



Title: Re: picturebox ONPAINT event
Post by: domenicomaria on April 27, 2019, 11:05:15 AM
with OBJECT DCL of CHAD WANLESS
with ACAD 2006
the SAME CODE
WORKS !

OT:
I was a FRIEND of CHAD WANLESS
But i have lost any contact with him !
Does somebody knows something about this ?
Title: Re: picturebox ONPAINT event
Post by: domenicomaria on April 28, 2019, 03:00:17 AM
what is the SEQUENCE ?

ON INITIALIZE
ON PAINT
and after
is the FORM SHOWN ?

Why
the ON PAINT event
seems to enter
in an INFINITE LOOP
while
the SAME CODE
contained in the ON PAINT defun,
WORKS PERFECTLY
when i CHANGE the SELECTION
in the list of LINETYPES ?

i need to UNDERSTAND WELL
the BEHAVIOR of the ON PAINT event,
because it is very PARTICULAR !
Title: Re: picturebox ONPAINT event
Post by: roy_043 on April 28, 2019, 11:52:39 AM
The OnPaint event of the pictureBox is triggered after the OnInitialize event of the form.
Maybe this example can help:
http://opendcl.com/forum/index.php?topic=1946.0
Title: Re: picturebox ONPAINT event
Post by: domenicomaria on April 28, 2019, 12:53:07 PM
yes
but it is not enough
to understand the behaviour
of my ONPAINT defun . . .
. . .
In my ONPAINT defun
i call a SUB-ROUTINE
. . .
I do ONLY THIS !
. . .

And I do the same
when the selection is changed
in the list of linetypes
. . .
and in this case
it works
. . .
while the same routine
creates an INFINITE LOOP
if I call it from the ONPAINT defun
. . .
Maybe
that it could depend from
dcl-picturebox-drawsolidrect ?

Title: Re: picturebox ONPAINT event
Post by: domenicomaria on April 28, 2019, 01:00:05 PM
see the attachment ...
Title: Re: picturebox ONPAINT event
Post by: domenicomaria on April 28, 2019, 01:07:14 PM
however
it does not depend  from
dcl-picturebox-drawsolidrect !

I removed it from the sub routine
and I got the same behavior
from the ONPAINT defun :
IT LOCKS ACAD !
Title: Re: picturebox ONPAINT event
Post by: domenicomaria on April 28, 2019, 01:28:48 PM
SOLVED !

I removed from the SUB-ROUTINE
called from the ONPAINT defun
these 2 DCL FUNCTIONS :
dcl-control-setbackcolor
dcl-PictureBox-Clear

and I added them
in the ONINITIALIZE defun . . .
...
Is it possible
that these 2 DCL FUNCTIONS
produce another ONPAINT EVENT
and this produces
an INFINITE LOOP  ? !
Title: Re: picturebox ONPAINT event
Post by: domenicomaria on April 28, 2019, 01:56:15 PM
TRY the ATTACHMENT !

It will LOCK AUTOCAD !
Title: Re: picturebox ONPAINT event
Post by: domenicomaria on April 28, 2019, 02:22:05 PM
However
dcl-control-setbackcolor does NOT create any problem ...
while
if we call
dcl-PictureBox-Clear
from the ONPAINT defun
this will LOCK ACAD.

Is this a BUG ?
Maybe NO !

Because there is no sense
to call dcl-PictureBox-Clear
when the ONPAINT event happens.

Because there is nothing to clear !