
#include <windows.h>
#include <commctrl.h>
#include "Resource.h"

BOOL EndDialog(HWND hDlg, INT_PTR nResult);

LRESULT CALLBACK DlgProc (HWND hWndDlg, UINT Msg,
			  WPARAM wParam, LPARAM lParam)
{
    INITCOMMONCONTROLSEX InitCtrlEx;

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

    switch (Msg) {

    case WM_INITDIALOG:
	CreateWindowEx(0, PROGRESS_CLASS, NULL,
		       WS_CHILD | WS_VISIBLE,
		       20, 20, 260, 17,
		       hWndDlg, NULL, hInst, NULL);
	return TRUE;

    case WM_COMMAND:
	switch(wParam) {
	case IDOK:
	    EndDialog(hWndDlg, 0);
	    return TRUE;
	case IDCANCEL:
	    EndDialog(hWndDlg, 0);
	    return TRUE;
	}
	break;

    default:
	break;
    }

    return FALSE;
}

INT WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
		    LPSTR lpCmdLine, int nCmdShow)
{
	hInst = hInstance;

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

	SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 220)); 

	lResult = SendMessage(hProgress, PBM_SETPOS, newpos, 0);

	return FALSE;
}
