The moment you call "DoAdvance", it queues up a "Paint" event to the program's message queue, then you proceed to "sleep" for 3 seconds (suspending the current thread for 3 seconds).

All the "Paint" events will happen after your procedure exits (you are running all your code in a single thread). If you want oProgressBar1 to paint before your procedure returns, you might have to resort to using undocumented function.

Frank Cheng