When you use a progress bar, you should create a thread to interact with the progress bar instead of doing it in your message pump, i.e WndProc function. It will make your application unresponsive, and it will make it frustrating for the end-user.
Just give it a blast in the main thread, it works by setting the range then at intervals changing the current setting within that range.