home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Freeware / Utilitare / VisualBoyAdvance-1.7.2 / src / win32 / ExportGSASnapshot.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-05-13  |  3.1 KB  |  118 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. // ExportGSASnapshot.cpp : implementation file
  20. //
  21.  
  22. #include "stdafx.h"
  23. #include "vba.h"
  24. #include "ExportGSASnapshot.h"
  25.  
  26. #include "../GBA.h"
  27. #include "../NLS.h"
  28.  
  29. #ifdef _DEBUG
  30. #define new DEBUG_NEW
  31. #undef THIS_FILE
  32. static char THIS_FILE[] = __FILE__;
  33. #endif
  34.  
  35. /////////////////////////////////////////////////////////////////////////////
  36. // ExportGSASnapshot dialog
  37.  
  38.  
  39. ExportGSASnapshot::ExportGSASnapshot(CString filename, CString title, CWnd* pParent /*=NULL*/)
  40.   : CDialog(ExportGSASnapshot::IDD, pParent)
  41. {
  42.   //{{AFX_DATA_INIT(ExportGSASnapshot)
  43.   m_desc = _T("");
  44.   m_notes = _T("");
  45.   m_title = _T("");
  46.   //}}AFX_DATA_INIT
  47.   m_title = title;
  48.   m_filename = filename;
  49.   char date[100];
  50.   char time[100];
  51.   
  52.   GetDateFormat(LOCALE_USER_DEFAULT,
  53.                 DATE_SHORTDATE,
  54.                 NULL,
  55.                 NULL,
  56.                 date,
  57.                 100);
  58.   GetTimeFormat(LOCALE_USER_DEFAULT,
  59.                 0,
  60.                 NULL,
  61.                 NULL,
  62.                 time,
  63.                 100);
  64.   m_desc.Format("%s %s", date, time);
  65. }
  66.  
  67.  
  68. void ExportGSASnapshot::DoDataExchange(CDataExchange* pDX)
  69. {
  70.   CDialog::DoDataExchange(pDX);
  71.   //{{AFX_DATA_MAP(ExportGSASnapshot)
  72.   DDX_Text(pDX, IDC_DESC, m_desc);
  73.   DDV_MaxChars(pDX, m_desc, 100);
  74.   DDX_Text(pDX, IDC_NOTES, m_notes);
  75.   DDV_MaxChars(pDX, m_notes, 512);
  76.   DDX_Text(pDX, IDC_TITLE, m_title);
  77.   DDV_MaxChars(pDX, m_title, 100);
  78.   //}}AFX_DATA_MAP
  79. }
  80.  
  81.  
  82. BEGIN_MESSAGE_MAP(ExportGSASnapshot, CDialog)
  83.   //{{AFX_MSG_MAP(ExportGSASnapshot)
  84.   ON_BN_CLICKED(ID_CANCEL, OnCancel)
  85.   ON_BN_CLICKED(ID_OK, OnOk)
  86.   //}}AFX_MSG_MAP
  87.   END_MESSAGE_MAP()
  88.  
  89.   /////////////////////////////////////////////////////////////////////////////
  90. // ExportGSASnapshot message handlers
  91.  
  92. BOOL ExportGSASnapshot::OnInitDialog() 
  93. {
  94.   CDialog::OnInitDialog();
  95.   CenterWindow();
  96.   
  97.   return TRUE;  // return TRUE unless you set the focus to a control
  98.                 // EXCEPTION: OCX Property Pages should return FALSE
  99. }
  100.  
  101. void ExportGSASnapshot::OnCancel() 
  102. {
  103.   EndDialog(FALSE);
  104. }
  105.  
  106. void ExportGSASnapshot::OnOk() 
  107. {
  108.   UpdateData(TRUE);
  109.  
  110.   bool result = CPUWriteGSASnapshot(m_filename, m_title, m_desc, m_notes);
  111.  
  112.   if(!result)
  113.     systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s",
  114.                   m_filename);
  115.   
  116.   EndDialog(TRUE);
  117. }
  118.