I posted the reply in a hurry. Here are some modifications.

Make hdc and hbrush global too. Or better, make all those global variables static in Progress_bar or, if you can, local to the function that calls Progress_bar. Globals are normally a bad idea.

Finally, when you're done with the progress bar call:
ReleaseDC (hwnd_your_progress_bar, hdc)