I want to know how to get a dialog box to display itself before I execute a function. This is what I have for the dialog box procedure:

Code:
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam) {
     switch(Message) {
          case WM_INITDIALOG:
               hProgress = CreateWindowEx(0, PROGRESS_CLASS, NULL, WS_CHILD | WS_VISIBLE, 5,35,76,20, hWndDlg, 0, hInst, NULL);
               SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0,100));
               SendMessage(hProgress, PBM_SETSTEP, (WPARAM)5, 0);
               return true;
          case WM_COMMAND:
               myFunction(hWndDlg); // This calls a function which updates the progress bar
               EndDialog(hWndDlg,0);
               return true;
          default:
               return DefWindowProc(hWndDlg, Message, wParam, lParam);
     }
}
The problem with that code is the dialog box isnt displayed UNTIL AFTER myFunction has completed its execution (and then the next line of code closes the dialog box, so you actually dont get to see the dialog box at all). I just want a simple progress bar that I can set the current status in myFunction (which this works properly if I could only get it to display the dialog box).

Any help is greatly appreciated. THANKS!!!