Author Topic: picturebox ONPAINT event  (Read 355 times)

domenicomaria

  • Member
  • *
  • Posts: 29
picturebox ONPAINT event
« 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



« Last Edit: April 27, 2019, 11:10:00 AM by domenicomaria »

domenicomaria

  • Member
  • *
  • Posts: 29
Re: picturebox ONPAINT event
« Reply #1 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 ?

domenicomaria

  • Member
  • *
  • Posts: 29
Re: picturebox ONPAINT event
« Reply #2 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 !
« Last Edit: April 28, 2019, 04:28:03 AM by domenicomaria »

roy_043

  • Sr. Member
  • ****
  • Posts: 361
Re: picturebox ONPAINT event
« Reply #3 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

domenicomaria

  • Member
  • *
  • Posts: 29
Re: picturebox ONPAINT event
« Reply #4 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 ?


domenicomaria

  • Member
  • *
  • Posts: 29
Re: picturebox ONPAINT event
« Reply #5 on: April 28, 2019, 01:00:05 PM »
see the attachment ...

domenicomaria

  • Member
  • *
  • Posts: 29
Re: picturebox ONPAINT event
« Reply #6 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 !

domenicomaria

  • Member
  • *
  • Posts: 29
Re: picturebox ONPAINT event
« Reply #7 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  ? !
« Last Edit: April 28, 2019, 01:33:51 PM by domenicomaria »

domenicomaria

  • Member
  • *
  • Posts: 29
Re: picturebox ONPAINT event
« Reply #8 on: April 28, 2019, 01:56:15 PM »
TRY the ATTACHMENT !

It will LOCK AUTOCAD !

domenicomaria

  • Member
  • *
  • Posts: 29
Re: picturebox ONPAINT event
« Reply #9 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 !

« Last Edit: April 28, 2019, 10:04:16 PM by domenicomaria »