-
Notifications
You must be signed in to change notification settings - Fork 7
/
CommentDlg.cpp
91 lines (70 loc) · 1.99 KB
/
CommentDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// CommentDlg.cpp : implementation file
//
#include "stdafx.h"
#include "DMSpec.h"
#include "CommentDlg.h"
using namespace Dialogs;
// CCommentDlg dialog
IMPLEMENT_DYNAMIC(CCommentDlg, CDialog)
CCommentDlg::CCommentDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCommentDlg::IDD, pParent)
{
}
CCommentDlg::~CCommentDlg()
{
}
void CCommentDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMMENT_EDIT, m_commentEdit);
}
BEGIN_MESSAGE_MAP(CCommentDlg, CDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()
// CCommentDlg message handlers
BOOL CCommentDlg::Create(UINT nID, CWnd* pParentWnd)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::Create(nID, pParentWnd);
}
BOOL CCommentDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CString tmpStr;
int hr = t/10000;
int mi = (t - hr*10000)/100;
int se = t % 100;
tmpStr.Format("Lat: %lf\tLong:%lf\tAlt:%lf\tTime: %d:%d%d", lat, lon, alt, hr, mi, se);
this->SetDlgItemText(IDC_GPS_LABEL, tmpStr);
this->m_commentEdit.SetFocus();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCommentDlg::OnBnClickedOk(){
int nLines;
char txt[512];
Common common;
FILE *f = fopen(outputDir + "\\Comments.txt", "a");
if(0 == f){
MessageBox("could not create/access comments.txt, nothing saved.");
return;
}
nLines = m_commentEdit.GetLineCount();
if(nLines == 0){
fclose(f);
return;
}
int hr = t/10000;
int mi = (t - hr*10000)/100;
int se = t % 100;
int length;
fprintf(f, "-------- Comment added on: %02d:%02d:%02d at lat: %lf\tlong: %lf\talt: %lf\n", hr, mi, se, lat, lon, alt);
for(int i = 0; i < nLines; ++i){
length = m_commentEdit.GetLine(i, txt, 512);
txt[length] = 0;
fprintf(f, "%s\n", txt);
}
fprintf(f, "\n");
fclose(f);
OnOK();
}