#include <windows.h>
#include "resource.h"

UINT LastBytes = sizeof (SYSTEMTIME) ;
UINT LastReps = 1 ;
extern DWORD TransferTime ;
extern LPDATAOBJECT lpd ;
extern UINT cfTimeData, cfTimeTest ;

BOOL CALLBACK TestDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_INITDIALOG:
		{
			SetDlgItemInt (hDlg, IDC_EDIT1, LastBytes, FALSE) ;
			SetDlgItemInt (hDlg, IDC_EDIT2, LastReps, FALSE) ;

			SetFocus (GetDlgItem (hDlg, IDC_EDIT1)) ;
			return FALSE ;
		}

		case WM_COMMAND:
		{
			if (LOWORD(wParam) == IDCANCEL)
			{
				EndDialog (hDlg, 0) ;
			}
			else if (LOWORD(wParam) == IDOK)
			{
				UINT i ;


				LastBytes = GetDlgItemInt (hDlg, IDC_EDIT1, NULL, FALSE) ;
				LastReps = GetDlgItemInt (hDlg, IDC_EDIT2, NULL, FALSE) ;

				DWORD InitTickCount = GetTickCount ( ) ;

				for (i = 0 ; i < LastReps ; i ++)
				{
					if (lpd)
					{
						FORMATETC fe ;
						STGMEDIUM stm ;

						fe.cfFormat = cfTimeTest ;
						fe.ptd = NULL ;
						fe.dwAspect = DVASPECT_CONTENT ;
						fe.lindex = LastBytes ;
						fe.tymed = TYMED_HGLOBAL ;

					 	if (SUCCEEDED(lpd->GetData (&fe, &stm)))
						{
							ReleaseStgMedium (&stm) ;
						}
					}

				}

				TransferTime = GetTickCount( ) - InitTickCount ;
				InvalidateRect (GetParent(hDlg), NULL, TRUE) ;
				EndDialog (hDlg, 0) ;
			}

			return TRUE ;
		}

	}

	return FALSE ;
}
