How to force an repaint after a file open dialog

M

Mitch

I'm having trouble with windows being left half drawn (for a while) after
the file open dialog is closed.

When the user selects a file in the file open dialog, the dialog closes and
the app starts to read the file (it takes about 5 seconds to read the file).
During the time that the app is reading the file however, the area that was
behind the file open dialog is not updated so it has a half drawn
appearance. How to I get the app window to repaint itself BEFORE it starts
the lengthy read operation. I've tried the Update and Invalidate methods,
but the problem remains.

Thanks

Mitch
 
P

Patrick Steele [MVP]

I'm having trouble with windows being left half drawn (for a while) after
the file open dialog is closed.

When the user selects a file in the file open dialog, the dialog closes and
the app starts to read the file (it takes about 5 seconds to read the file).
During the time that the app is reading the file however, the area that was
behind the file open dialog is not updated so it has a half drawn
appearance. How to I get the app window to repaint itself BEFORE it starts
the lengthy read operation. I've tried the Update and Invalidate methods,
but the problem remains.

Start up a seperate thread to read the file data in. That way, the UI
thread can respond to the repaint message sent to it after the file open
dialog is closed.
 
?

=?ISO-8859-1?Q?Christian_Fr=F6schlin?=

Mitch said:
appearance. How to I get the app window to repaint itself BEFORE it starts
the lengthy read operation. I've tried the Update and Invalidate methods,
but the problem remains.

Maybe it helps to call Application.DoEvents
 
M

Mitch

A separate thread is a good idea. Especially if the read time starts to
exceed 10 seconds.

The Application.DoEvents also worked well.

Thanks for the help.
 

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