Picture Resize Event

Z

Z D

Hello,

BACKGROUND:
==============
I've created a Windows User Control that contains an Image Control (among
other controls).

The user control handles the picture resize event. Whenever the parent that
holds my user control is resized, I resize my image so that it uses the
maximum available space. Note: It takes about 2 seconds to regenerate the
newly sized image (lots of complex stuff going on).


THE PROBLEM:
==============
If the user has "Show contents while dragging window" feature enabled in
windows then while they are resizing resizing the parent form the picture
resize event keeps firing for every pixel the mouse is moved. This is a big
problem because the UI just freezes while its waiting for the resize to
occur (takes over 2 seconds!).

My question is: How do I go about fixing this? Is there a picture resize
completed event? That would be perfect, but unfortunately I cant find one.

I've even tried to detect if the mouse is down in the resize event and if it
is then I dont do a refresh. Problem is that when they stop resizing and
release the mouse button then the ressize event isn't fired one last time so
my picture size is not changed.

Note: if the user does not have "show window contents while dragging..."
enabled then things work fine as the picture resize is called only once when
the resize is completed. Is there any way to get the same thing to work
when "show contenets while dragging..." is enabled?

Any suggestions would be greatly appreciated.

Thanks
 
G

Guest

Hi Z D

Why don't you try implementing a timeout based solution - when the resize
starts, don't actually kick off resize code until a certain amount of time
has elapsed. Then if the next resize event comes in sooner, you don't have to
start the recalculation of the image. You could experiment with different
timeouts, but probably 100ms or so would be OK to catch the situation you are
describing, and will still make the user feel in control.

HTH

Nigel Armstrong
 
Z

Z D

Hi Nigel,

Thanks for your suggestion, I was playing around with that idea but I was
hoping I wouldnt have to resort to it! :)

-ZD
 
P

Peder Y

....just a quick thought as I'm not on my Windows machine right now.
Could you move the code to the MouseUp event of the form?

- Peder -
 

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

Top