-
Notifications
You must be signed in to change notification settings - Fork 4
/
ProgressDlg.cpp
141 lines (107 loc) · 2.78 KB
/
ProgressDlg.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// ProgressDlg.cpp: 实现文件
//
#include "pch.h"
#include "AutoEye.h"
#include "afxdialogex.h"
#include "ProgressDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CProgressDlg 对话框
enum
{
WM_EXITDIALOG = WM_USER + 1
};
LPCTSTR CProgressDlg::m_lpszInfo = _T("正在努力处理中,请耐心等待");
IMPLEMENT_DYNAMIC(CProgressDlg, CDialog)
CProgressDlg::CProgressDlg(int *phAutoHandle,
BasicInformation *pBaseInfo,
CString strInputFile,
BOOL bAdvance,
BOOL bCmdMode,
CWnd* pParent /*=nullptr*/)
: CDialog(IDD_PROGRESS, pParent)
, m_strStatus(m_lpszInfo)
{
m_phAutoHandle = phAutoHandle;
m_pBaseInfo = pBaseInfo;
m_strInputFile = strInputFile;
m_nCount = 0;
m_bAdvance = bAdvance;
m_bCmdMode = bCmdMode;
m_nResult = ErrorUnknow;
m_pThreadDecompile = nullptr;
}
CProgressDlg::~CProgressDlg()
{
if (m_pThreadDecompile != nullptr)
{
m_pThreadDecompile->join();
}
}
void CProgressDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_STATIC_STATUS, m_strStatus);
}
BEGIN_MESSAGE_MAP(CProgressDlg, CDialog)
ON_WM_TIMER()
END_MESSAGE_MAP()
// CProgressDlg 消息处理程序
void CProgressDlg::OnTimer(UINT_PTR nIDEvent)
{
m_nCount++;
m_nCount = m_nCount % 20;
CString strDot;
for (int i=0; i<m_nCount; i++)
{
strDot += _T(".");
}
m_strStatus = CString(m_lpszInfo) + strDot;
UpdateData(FALSE);
CDialog::OnTimer(nIDEvent);
}
BOOL CProgressDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if (m_bCmdMode && !IsDebuggerPresent())
{
AttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(), NULL), GetCurrentThreadId(), TRUE);
SetForegroundWindow();
SetFocus();
AttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(), NULL), GetCurrentThreadId(), FALSE);
}
SetTimer(0, 100, NULL);
m_pThreadDecompile = std::unique_ptr<std::thread>(new std::thread([this]()
{
if (m_bAdvance)
{
m_nResult = au3engine_openfile_advance(m_phAutoHandle, m_pBaseInfo, m_strInputFile, nullptr);
}
else
{
m_nResult = au3engine_openfile_general(m_phAutoHandle, m_pBaseInfo, m_strInputFile, nullptr);
}
PostMessage(WM_EXITDIALOG);
}));
if (m_pThreadDecompile == nullptr)
{
PostMessage(WM_EXITDIALOG);
}
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CProgressDlg::OnOK()
{
}
void CProgressDlg::OnCancel()
{
}
BOOL CProgressDlg::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == WM_EXITDIALOG)
{
CDialog::OnOK();
}
return CDialog::PreTranslateMessage(pMsg);
}