-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSendFileDlg.cpp
More file actions
96 lines (76 loc) · 2.52 KB
/
Copy pathSendFileDlg.cpp
File metadata and controls
96 lines (76 loc) · 2.52 KB
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
92
93
94
95
96
// SendFileDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SuperTerm.h"
#include "SendFileDlg.h"
#include "HistoryComboBox.h"
#include ".\sendfiledlg.h"
// CSendFileDlg dialog
IMPLEMENT_DYNAMIC(CSendFileDlg, CDialog)
CSendFileDlg::CSendFileDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSendFileDlg::IDD, pParent)
{
m_LineInterval = 100; //100ms
}
CSendFileDlg::~CSendFileDlg()
{
}
void CSendFileDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CSendFileDlg, CDialog)
ON_BN_CLICKED(IDC_BUTTON1, OnFileBrowse)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
END_MESSAGE_MAP()
int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg,LPARAM lParam,LPARAM lpData)
{
if(uMsg == BFFM_INITIALIZED) {
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
}
return 0;
}
// CSendFileDlg message handlers
void CSendFileDlg::OnFileBrowse()
{
CString InitFolderPath;
CFileDialog fOpenDlg(TRUE, _T(""), _T("*.*"), OFN_FILEMUSTEXIST, _T("*.*"), this);
fOpenDlg.m_pOFN->lpstrTitle = _T("Select Send File");
fOpenDlg.m_pOFN->lpstrInitialDir = InitFolderPath;
if (fOpenDlg.DoModal()==IDOK) {
((CComboBox*)GetDlgItem(IDC_COMBO_FILE))->SetWindowText(fOpenDlg.GetPathName());
}
}
BOOL CSendFileDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_IniFile = m_Ini.GetIniFilePath();
((CHistoryComboBox*)GetDlgItem(IDC_COMBO_FILE))->LoadHistoryList(m_IniFile, _T("Send"), _T("File"));
TCHAR Buffer[1024];
m_Ini.GetString (_T("SendFile"), _T("LineInterval"), Buffer, sizeof(Buffer), _T("100"));
((CEdit *)GetDlgItem(IDC_INTERVAL))->SetWindowText(Buffer);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSendFileDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
CString strLineInterval;
((CEdit *)GetDlgItem(IDC_INTERVAL))->GetWindowText(strLineInterval);
m_LineInterval = _tstol(strLineInterval);
if (m_LineInterval <= 0 && m_LineInterval >= 10000) {
AfxMessageBox(_T("Invalue Line Interfavlue value!"));
return;
} else {
m_Ini.WriteInt (_T("SendFile"), _T("LineInterval"), m_LineInterval);
}
((CHistoryComboBox*)GetDlgItem(IDC_COMBO_FILE))->SaveHistoryList(m_IniFile, _T("Send"), _T("File"));
((CComboBox*)GetDlgItem(IDC_COMBO_FILE))->GetWindowText(m_FilePath);
if (GetFileAttributes(m_FilePath) != INVALID_FILE_ATTRIBUTES) {
OnOK();
} else {
m_FilePath.Empty();
AfxMessageBox (_T("Invalid File Path!"));
}
}