setting Control.Region takes too much time

  • Thread starter Thread starter Sagaert Johan
  • Start date Start date
S

Sagaert Johan

Hi

I have a customcontrol that has a boolean state variable.
The control is placed over a picturebox.

Depending on the value i assign a new Region to the control.
The region is simple and contructed from a graphicpath containing 1 ellipse.
(size no more then 100 pixels)

if (state)
this.Region=new Region(pathA);
else
this.Region=new Region(pathB);


This construction takes 300ms to execute on a 600Mhz Mainboard.

Can someone explain why ?

Whats the workaround ?

Johan
 
Hello Sagaert,
This construction takes 300ms to execute on a 600Mhz Mainboard.

So? I don't think this functionality has been created with the idea in
mind that you'd change the region around in a busy loop, and for
initialization purposes I don't see how 300ms are much of a problem. Of
course it's not fast... see below.
Can someone explain why ?

One reason is probably that rather slow machine - 600MHz is not a lot
these days. I'm tempted to use a lot stronger words :-)


Oliver Sturm
 
Hi

I removed the underlaying control with the backgroundimage set and replaced
it by a simple picturebox and now the regionchange only takes about 10ms

So it seems setting the region involves some repainting of the background
control.
 
Hello Sagaert,
I removed the underlaying control with the backgroundimage set and replaced
it by a simple picturebox and now the regionchange only takes about 10ms

So it seems setting the region involves some repainting of the background
control.

Ah, that's interesting - I'm sure it does involve repainting, but
apparently that control you had in there before took a while longer to do
that than you should expect even on that machine :-) Good to hear you
figured it out.


Oliver Sturm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top