home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Freeware / Utilitare / VisualBoyAdvance-1.7.2 / src / win32 / ModeConfirm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-05-13  |  2.7 KB  |  114 lines

  1. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
  2. // Copyright (C) 1999-2003 Forgotten
  3. // Copyright (C) 2004 Forgotten and the VBA development team
  4.  
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2, or(at your option)
  8. // any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software Foundation,
  17. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18.  
  19. // ModeConfirm.cpp : implementation file
  20. //
  21.  
  22. #include "stdafx.h"
  23. #include "vba.h"
  24. #include "ModeConfirm.h"
  25.  
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // ModeConfirm dialog
  34.  
  35.  
  36. ModeConfirm::ModeConfirm(CWnd* pParent /*=NULL*/)
  37.   : CDialog(ModeConfirm::IDD, pParent)
  38. {
  39.   //{{AFX_DATA_INIT(ModeConfirm)
  40.   // NOTE: the ClassWizard will add member initialization here
  41.   //}}AFX_DATA_INIT
  42. }
  43.  
  44.  
  45. void ModeConfirm::DoDataExchange(CDataExchange* pDX)
  46. {
  47.   CDialog::DoDataExchange(pDX);
  48.   //{{AFX_DATA_MAP(ModeConfirm)
  49.   // NOTE: the ClassWizard will add DDX and DDV calls here
  50.   //}}AFX_DATA_MAP
  51. }
  52.  
  53.  
  54. BEGIN_MESSAGE_MAP(ModeConfirm, CDialog)
  55.   //{{AFX_MSG_MAP(ModeConfirm)
  56.   ON_BN_CLICKED(ID_CANCEL, OnCancel)
  57.   ON_BN_CLICKED(ID_OK, OnOk)
  58.   ON_WM_DESTROY()
  59.   ON_WM_TIMER()
  60.   //}}AFX_MSG_MAP
  61.   END_MESSAGE_MAP()
  62.  
  63.   /////////////////////////////////////////////////////////////////////////////
  64. // ModeConfirm message handlers
  65.  
  66. void ModeConfirm::OnCancel() 
  67. {
  68.   EndDialog(FALSE);
  69. }
  70.  
  71. void ModeConfirm::OnOk() 
  72. {
  73.   EndDialog(TRUE);
  74. }
  75.  
  76. void ModeConfirm::OnDestroy() 
  77. {
  78.   CDialog::OnDestroy();
  79.   
  80.   KillTimer(timer);
  81.   timer = 0;
  82. }
  83.  
  84. BOOL ModeConfirm::OnInitDialog() 
  85. {
  86.   CDialog::OnInitDialog();
  87.   
  88.   timer = SetTimer(0, 1000, NULL);
  89.  
  90.   count = 10;
  91.  
  92.   CString buffer;
  93.   buffer.Format("%d", count);
  94.  
  95.   GetDlgItem(IDC_TIMER)->SetWindowText(buffer);
  96.  
  97.   CenterWindow(theApp.m_pMainWnd);
  98.   
  99.   return TRUE;  // return TRUE unless you set the focus to a control
  100.                 // EXCEPTION: OCX Property Pages should return FALSE
  101. }
  102.  
  103. void ModeConfirm::OnTimer(UINT nIDEvent) 
  104. {
  105.   CString buffer;  
  106.   count--;
  107.   if(count == 0)
  108.     EndDialog(FALSE);
  109.   buffer.Format("%d", count);
  110.   GetDlgItem(IDC_TIMER)->SetWindowText(buffer);
  111.   
  112.   CDialog::OnTimer(nIDEvent);
  113. }
  114.