And how would you do it with a timer? And if you wanted to load actual files, it wouldn't be in a loop, it would just run through the code like so.
Code:
//Load database

//Then advance progress bar

//Load savegame

//Advance progress bar - and so forth
I now changed the code to this, which works. How do you get the fancy styles for the progress bar colour, like that fancy green for Win7? Also, after I click load, and it finishes, it says it's not responding and crashes. Is it not ending properly?

Code:
#include <windows.h>
#include <commctrl.h>
#include "progress_bar.h"

#define length 100000

//---------------------------------------------------------------------------
HWND hWnd;
HINSTANCE hInst;
LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
HWND hwndpb;
//---------------------------------------------------------------------------
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
				   LPSTR lpCmdLine, int nCmdShow)
{
	hInst = hInstance;

	DialogBox(hInst, MAKEINTRESOURCE(IDD_CONTROLS_DLG),
	          hWnd, reinterpret_cast<DLGPROC>(DlgProc));
	          
    INITCOMMONCONTROLSEX InitCtrlEx;

	InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
	InitCtrlEx.dwICC  = ICC_PROGRESS_CLASS;
	InitCommonControlsEx(&InitCtrlEx);

	return FALSE;
}
//---------------------------------------------------------------------------
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg,
		       WPARAM wParam, LPARAM lParam)
{

	switch(Msg)
	{
	case WM_INITDIALOG:
		hwndpb = CreateWindowEx(0, PROGRESS_CLASS, NULL,
		               WS_CHILD | WS_VISIBLE | PBS_SMOOTH ,
			      20, 20, 260, 17,
			      hWndDlg, (HMENU)IDC_PROGBAR, hInst, NULL);
			      
		return TRUE;

	case WM_COMMAND:
		switch(wParam)
		{
		case IDLOAD: 
        {
            int pb_pos;
            SendMessage(hwndpb, PBM_SETRANGE, 0, MAKELPARAM(0, length ));
			while(pb_pos != length)
            {           
                        pb_pos = SendMessage(hwndpb, PBM_GETPOS, 0, 0);
                        pb_pos++;
                        SendMessage(hwndpb, PBM_SETPOS, pb_pos, 0);
            }
			return TRUE;
        }                break;
		case IDCANCEL:
        {
			EndDialog(hWndDlg, 0);
			return TRUE;}
		}
		break;
	}

	return FALSE;
}