1 #include "stdafx.h"
2 #include "vba.h"
3 #include "ExportGSASnapshot.h"
4
5 #include "../gba/GBA.h"
6 #include "../NLS.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
13
14 /////////////////////////////////////////////////////////////////////////////
15 // ExportGSASnapshot dialog
16
17
ExportGSASnapshot(CString filename,CString title,CWnd * pParent)18 ExportGSASnapshot::ExportGSASnapshot(CString filename, CString title, CWnd* pParent /*=NULL*/)
19 : CDialog(ExportGSASnapshot::IDD, pParent)
20 {
21 //{{AFX_DATA_INIT(ExportGSASnapshot)
22 m_desc = _T("");
23 m_notes = _T("");
24 m_title = _T("");
25 //}}AFX_DATA_INIT
26 m_title = title;
27 m_filename = filename;
28 char date[100];
29 char time[100];
30
31 GetDateFormat(LOCALE_USER_DEFAULT,
32 DATE_SHORTDATE,
33 NULL,
34 NULL,
35 date,
36 100);
37 GetTimeFormat(LOCALE_USER_DEFAULT,
38 0,
39 NULL,
40 NULL,
41 time,
42 100);
43 m_desc.Format("%s %s", date, time);
44 }
45
46
DoDataExchange(CDataExchange * pDX)47 void ExportGSASnapshot::DoDataExchange(CDataExchange* pDX)
48 {
49 CDialog::DoDataExchange(pDX);
50 //{{AFX_DATA_MAP(ExportGSASnapshot)
51 DDX_Text(pDX, IDC_DESC, m_desc);
52 DDV_MaxChars(pDX, m_desc, 100);
53 DDX_Text(pDX, IDC_NOTES, m_notes);
54 DDV_MaxChars(pDX, m_notes, 512);
55 DDX_Text(pDX, IDC_TITLE, m_title);
56 DDV_MaxChars(pDX, m_title, 100);
57 //}}AFX_DATA_MAP
58 }
59
60
BEGIN_MESSAGE_MAP(ExportGSASnapshot,CDialog)61 BEGIN_MESSAGE_MAP(ExportGSASnapshot, CDialog)
62 //{{AFX_MSG_MAP(ExportGSASnapshot)
63 ON_BN_CLICKED(ID_CANCEL, OnCancel)
64 ON_BN_CLICKED(ID_OK, OnOk)
65 //}}AFX_MSG_MAP
66 END_MESSAGE_MAP()
67
68 /////////////////////////////////////////////////////////////////////////////
69 // ExportGSASnapshot message handlers
70
71 BOOL ExportGSASnapshot::OnInitDialog()
72 {
73 CDialog::OnInitDialog();
74 CenterWindow();
75
76 return TRUE; // return TRUE unless you set the focus to a control
77 // EXCEPTION: OCX Property Pages should return FALSE
78 }
79
OnCancel()80 void ExportGSASnapshot::OnCancel()
81 {
82 EndDialog(FALSE);
83 }
84
OnOk()85 void ExportGSASnapshot::OnOk()
86 {
87 UpdateData(TRUE);
88
89 bool result = CPUWriteGSASnapshot(m_filename, m_title, m_desc, m_notes);
90
91 if(!result)
92 systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s",
93 m_filename);
94
95 EndDialog(TRUE);
96 }
97