|
@@ -22,6 +22,9 @@
|
|
|
#define MAX_SWITCH_LEN 16
|
|
|
#define MAX_SENDDATA 512
|
|
|
|
|
|
+#define TMSG_QUITE_THREAD 9
|
|
|
+#define TMSG_START_LEARN 10
|
|
|
+
|
|
|
#ifdef _DEBUG
|
|
|
#undef THIS_FILE
|
|
|
static char THIS_FILE[]=__FILE__;
|
|
@@ -159,7 +162,8 @@ int CPropertiesWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
|
|
|
|
LoadSignals();
|
|
|
m_wndSignalCombo.SelectString(0, Global::g_Config.twUseSignal.c_str());
|
|
|
- LoadKeyInfo(m_vtKeyInfo, Global::g_Config.twSignaldir + _T("\\") + Global::g_Config.twUseSignal + _T(".xml"));
|
|
|
+ m_strXMLPath = Global::g_Config.twSignaldir + _T("\\") + Global::g_Config.twUseSignal + _T(".xml");
|
|
|
+ LoadKeyInfo(m_vtKeyInfo, m_strXMLPath);
|
|
|
|
|
|
AdjustLayout();
|
|
|
return 0;
|
|
@@ -221,7 +225,8 @@ void CPropertiesWnd::OnCbnSelchangeSingals()
|
|
|
WritePrivateProfileString("TestWizard", "useSignal", strSignal.GetString(), Global::g_szConfig);
|
|
|
|
|
|
SetAllBTNUnUsed();
|
|
|
- LoadKeyInfo(m_vtKeyInfo, Global::g_Config.twSignaldir + _T("\\") + Global::g_Config.twUseSignal + _T(".xml"));
|
|
|
+ m_strXMLPath = Global::g_Config.twSignaldir + _T("\\") + Global::g_Config.twUseSignal + _T(".xml");
|
|
|
+ LoadKeyInfo(m_vtKeyInfo, m_strXMLPath);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -426,7 +431,7 @@ void CPropertiesWnd::LoadKeyInfo(std::vector<KeyInfo> &vtKeyInfo, TString path)
|
|
|
AdjustLayout();
|
|
|
}
|
|
|
|
|
|
-void CPropertiesWnd::SaveKeyInfo(std::vector<KeyInfo> &vtKeyInfo, TString path)
|
|
|
+void CPropertiesWnd::SaveKeyInfo()
|
|
|
{
|
|
|
tinyxml2::XMLDocument doc;
|
|
|
tinyxml2::XMLElement* pXmlRoot = NULL;
|
|
@@ -492,7 +497,7 @@ void CPropertiesWnd::SaveKeyInfo(std::vector<KeyInfo> &vtKeyInfo, TString path)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- doc.SaveFile(path.c_str());
|
|
|
+ doc.SaveFile(m_strXMLPath.c_str());
|
|
|
}
|
|
|
|
|
|
void CPropertiesWnd::ConvertOldSignalsToNew(std::string strOldSignal, std::string strNewSignal)
|
|
@@ -793,7 +798,7 @@ void CPropertiesWnd::LearnInfraedSignal(UINT uId, KeyInfo *pKey)
|
|
|
|
|
|
if (m_dwThreadId)
|
|
|
{
|
|
|
- PostThreadMessage(m_dwThreadId, 10, uId, 0);
|
|
|
+ PostThreadMessage(m_dwThreadId, TMSG_START_LEARN, uId, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -811,7 +816,12 @@ DWORD WINAPI CPropertiesWnd::ThreadLearn(LPVOID lpParam)
|
|
|
MSG msg;
|
|
|
if (GetMessage(&msg, NULL, 0, 0))
|
|
|
{
|
|
|
- if (msg.message == 10)
|
|
|
+ if (msg.message == TMSG_QUITE_THREAD)
|
|
|
+ {
|
|
|
+ pthis->SaveKeyInfo();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else if (msg.message == TMSG_START_LEARN )
|
|
|
{
|
|
|
DWORD dwTickCount = ::GetTickCount64();
|
|
|
while (GetTickCount64() - dwTickCount < 60000)
|
|
@@ -897,10 +907,14 @@ BOOL CPropertiesWnd::PreTranslateMessage(MSG* pMsg)
|
|
|
{
|
|
|
Global::g_bLearn = !Global::g_bLearn;
|
|
|
if (m_dwThreadId == 0 && Global::g_bLearn)
|
|
|
- {
|
|
|
CreateThread(NULL, 0, ThreadLearn, this, 0, &m_dwThreadId);
|
|
|
- }
|
|
|
+
|
|
|
+ // 关闭线程;
|
|
|
+ if (!Global::g_bLearn)
|
|
|
+ PostThreadMessage(m_dwThreadId, TMSG_QUITE_THREAD, 0, 0);
|
|
|
+
|
|
|
MessageBox(Global::g_bLearn ? _T("开启学习红外") : _T("关闭红外学习"), _T("提示"), MB_OK);
|
|
|
+
|
|
|
return TRUE;
|
|
|
}
|
|
|
}
|