// CPAMDgIf.cpp : implementation file
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"

#include "IADDgIf.hpp"

#include "_IADItrf.hpp"

#define C_INFO_DIALOG_TIMER			70	//An Id for the timer
#define C_TEMPO_TIMER						100	//(ms)

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// IAD_InformationDialog dialog

BEGIN_MESSAGE_MAP(IAD_InformationDialog, CDialog)
	//{{AFX_MSG_MAP(IAD_InformationDialog)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


//**************************************************************************
IAD_InformationDialog::IAD_InformationDialog(CWnd* pParent, CString csMessage)
	: CDialog(IAD_InformationDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(IAD_InformationDialog)
	m_csMessage = csMessage;
	//}}AFX_DATA_INIT

	m_hOldInstance = AfxGetResourceHandle();
	AfxSetResourceHandle(g_stIADDLLIdentity.hModule);
}

//**************************************************************************
IAD_InformationDialog::~IAD_InformationDialog()
{
	AfxSetResourceHandle(m_hOldInstance);
}

//***************************************************************************
void IAD_InformationDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(IAD_InformationDialog)
	DDX_Text(pDX, IDC_STATIC_TEXT, m_csMessage);
	//}}AFX_DATA_MAP
}


/////////////////////////////////////////////////////////////////////////////
// IAD_InformationDialog message handlers

//***************************************************************************
BOOL IAD_InformationDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	//Init. timer
	SetTimer(C_INFO_DIALOG_TIMER, C_TEMPO_TIMER, NULL);

	//Loads Bitmaps
	m_a_cbBitmaps[0].LoadBitmap(IDB_BITMAP_INFO1);
	m_a_cbBitmaps[1].LoadBitmap(IDB_BITMAP_INFO2);
	m_a_cbBitmaps[2].LoadBitmap(IDB_BITMAP_INFO3);
	m_a_cbBitmaps[3].LoadBitmap(IDB_BITMAP_INFO4);
	m_a_cbBitmaps[4].LoadBitmap(IDB_BITMAP_INFO5);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

//***************************************************************************
void IAD_InformationDialog::OnOK() 
{
	KillTimer(C_INFO_DIALOG_TIMER);
	
	EndDialog(IDOK);
}

//***************************************************************************
void IAD_InformationDialog::OnTimer(UINT nIDEvent) 
{
	static BOOL s_bFirstPass = TRUE;
	static char s_cCurrentBitmapIndex = -1; //To begin with first bitmap
	static char s_cIndexIncrement = 1;

	s_cCurrentBitmapIndex += s_cIndexIncrement;
	if ( ! s_bFirstPass )
	{
		if ( s_cCurrentBitmapIndex	% (C_NUMBER_OF_BITMAPS-1) == 0 )
			s_cIndexIncrement = -s_cIndexIncrement;
	}
	else
		s_bFirstPass = FALSE;

	((CStatic *)GetDlgItem(IDC_STATIC_IMAGE))->SetBitmap(HBITMAP(m_a_cbBitmaps[s_cCurrentBitmapIndex]));

	CDialog::OnTimer(nIDEvent);
}
