// CPAMDgQu.cpp : implementation file ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "IADDgQu.hpp" #include "_IADItrf.hpp" #define C_QUESTION_DIALOG_TIMER 69 //An Id for the timer #define C_TEMPO_TIMER 60 //(ms) #define C_NUMBER_OF_FRAMES 15 #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // IAD_QuestionDialog dialog BEGIN_MESSAGE_MAP(IAD_QuestionDialog, CDialog) //{{AFX_MSG_MAP(IAD_QuestionDialog) ON_BN_CLICKED(IDNO, OnNo) ON_BN_CLICKED(IDYES, OnYes) ON_WM_TIMER() //}}AFX_MSG_MAP END_MESSAGE_MAP() //************************************************************************** IAD_QuestionDialog::IAD_QuestionDialog(CWnd* pParent, CString csMessage) : CDialog(IAD_QuestionDialog::IDD, pParent) { //{{AFX_DATA_INIT(IAD_QuestionDialog) m_csMessage = csMessage; //}}AFX_DATA_INIT m_hOldInstance = AfxGetResourceHandle(); AfxSetResourceHandle(g_stIADDLLIdentity.hModule); } //************************************************************************** IAD_QuestionDialog::~IAD_QuestionDialog() { AfxSetResourceHandle(m_hOldInstance); } //*************************************************************************** void IAD_QuestionDialog::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(IAD_QuestionDialog) DDX_Text(pDX, IDC_STATIC_QUESTION, m_csMessage); //}}AFX_DATA_MAP } ///////////////////////////////////////////////////////////////////////////// // IAD_QuestionDialog message handlers //*************************************************************************** BOOL IAD_QuestionDialog::OnInitDialog() { CDialog::OnInitDialog(); //Init. timer SetTimer(C_QUESTION_DIALOG_TIMER, C_TEMPO_TIMER, NULL); //Loads Bitmaps m_cbBitmap.LoadBitmap(IDB_BITMAP_QUESTION); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } //*************************************************************************** void IAD_QuestionDialog::OnNo() { KillTimer(C_QUESTION_DIALOG_TIMER); EndDialog(IDNO); } //*************************************************************************** void IAD_QuestionDialog::OnYes() { KillTimer(C_QUESTION_DIALOG_TIMER); EndDialog(IDYES); } //*************************************************************************** void IAD_QuestionDialog::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_FRAMES-1) == 0 ) s_cIndexIncrement = -s_cIndexIncrement; } else s_bFirstPass = FALSE; ((CStatic *)GetDlgItem(IDC_STATIC_IMAGE))->SetBitmap(HBITMAP(m_a_cbBitmaps[s_cCurrentBitmapIndex])); */ static BOOL s_bFirstPass = TRUE; static CRect crRect; static char s_cCurrentIndex = -1; static char s_cIndexIncrement = 1; s_cCurrentIndex += s_cIndexIncrement; if ( s_bFirstPass ) { crRect.top = 0; crRect.bottom = 56; crRect.left = 0; crRect.right = 56; s_bFirstPass = FALSE; } else { if ( s_cCurrentIndex % (C_NUMBER_OF_FRAMES-1) == 0 ) s_cIndexIncrement = -s_cIndexIncrement; } //Computes Rect crRect.left = (56 * s_cCurrentIndex)/ C_NUMBER_OF_FRAMES; crRect.right = 56 - (56 * s_cCurrentIndex)/ C_NUMBER_OF_FRAMES; CClientDC dc(GetDlgItem(IDC_EDIT_BIDON)); CDC memDC; memDC.CreateCompatibleDC(&dc); memDC.SelectObject(m_cbBitmap); dc.StretchBlt( crRect.left, crRect.top, crRect.Width(), crRect.Height(), &memDC, 0, 0, 56, 56, SRCCOPY); CDialog::OnTimer(nIDEvent); }