|
|
@@ -11,18 +11,7 @@
|
|
|
|
|
|
#include <atltypes.h>
|
|
|
|
|
|
-void RegKeyboardRawInput(HWND hWnd)
|
|
|
-{
|
|
|
- RAWINPUTDEVICE rawInputDevice[1];
|
|
|
- rawInputDevice[0].usUsagePage = 0x01;//设备类
|
|
|
- rawInputDevice[0].usUsage = 0x06;//设备类内的具体设备
|
|
|
- rawInputDevice[0].dwFlags = RIDEV_INPUTSINK;//意味着即使窗口失去焦点位置,仍然会一直接收输入消息
|
|
|
- rawInputDevice[0].hwndTarget = hWnd;
|
|
|
- if (RegisterRawInputDevices(rawInputDevice, 1, sizeof(rawInputDevice[0])) == FALSE)
|
|
|
- {
|
|
|
- printf("RegisterRawInputDevices failed");
|
|
|
- }
|
|
|
-}
|
|
|
+#include "CLoginWnd.h"
|
|
|
|
|
|
void CValueWnd::Notify(TNotifyUI& msg)
|
|
|
{
|
|
|
@@ -44,6 +33,9 @@ void CValueWnd::Init()
|
|
|
//抢焦点
|
|
|
std::thread(&CValueWnd::TopMostWnd, this).detach();
|
|
|
|
|
|
+ //任务+1
|
|
|
+ m_nTaskNum++;
|
|
|
+
|
|
|
//注册热键
|
|
|
UpdateRegisterHotKey();
|
|
|
|
|
|
@@ -83,13 +75,14 @@ void CValueWnd::Init()
|
|
|
m_tess.SetPageSegMode(tesseract::PageSegMode::PSM_SINGLE_LINE);
|
|
|
m_tess.SetVariable("save_best_choices", "T");
|
|
|
|
|
|
+ //开启键盘输入监听
|
|
|
+ RegKeyboardRawInput();
|
|
|
+
|
|
|
//再安装钩子
|
|
|
BOOL ret = InstallHook();
|
|
|
|
|
|
//开始启动监听
|
|
|
RestartWatch();
|
|
|
-
|
|
|
- RegKeyboardRawInput(m_hWnd);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -97,7 +90,7 @@ void CValueWnd::Init()
|
|
|
**/
|
|
|
void CValueWnd::TopMostWnd()
|
|
|
{
|
|
|
- while (true)
|
|
|
+ while (m_is_quit == false)
|
|
|
{
|
|
|
::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
|
|
|
|
|
|
@@ -106,8 +99,12 @@ void CValueWnd::TopMostWnd()
|
|
|
//::SendMessage(m_shoukuanHWND, WM_SHOUKUAN_UPDATE_FOCUS, NULL, NULL);
|
|
|
}
|
|
|
|
|
|
- Sleep(300);
|
|
|
+ Sleep(100);
|
|
|
}
|
|
|
+
|
|
|
+ m_nTaskNum--;
|
|
|
+
|
|
|
+ //线程退出
|
|
|
}
|
|
|
|
|
|
void CValueWnd::RestartWatch()
|
|
|
@@ -115,16 +112,24 @@ void CValueWnd::RestartWatch()
|
|
|
std::thread(&CValueWnd::StartWatchWork, this).detach();
|
|
|
}
|
|
|
|
|
|
+void CValueWnd::StopWatch()
|
|
|
+{
|
|
|
+ m_isWatchWork = false;
|
|
|
+
|
|
|
+ while (m_is_xunichuangkou_working || m_is_chuangkou_working || m_is_orc_working)
|
|
|
+ {
|
|
|
+ //等这3个线程全部退出
|
|
|
+ Sleep(100);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
*根据当前数据库的设置,重启监听
|
|
|
**/
|
|
|
void CValueWnd::StartWatchWork()
|
|
|
{
|
|
|
//先暂停已有的监控
|
|
|
- m_isWatchWork = false;
|
|
|
-
|
|
|
- //等待2秒,这2秒就是等已有的监控线程自动退出
|
|
|
- Sleep(2000);
|
|
|
+ StopWatch();
|
|
|
|
|
|
//然后开始工作
|
|
|
m_isWatchWork = true;
|
|
|
@@ -192,6 +197,8 @@ void CValueWnd::ReadXunichuankouValue()
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ m_is_xunichuangkou_working = true;
|
|
|
+
|
|
|
char a[1024] = { 0 };
|
|
|
|
|
|
//检查监控模式和波特率,如果变了就关闭掉
|
|
|
@@ -213,10 +220,14 @@ void CValueWnd::ReadXunichuankouValue()
|
|
|
}
|
|
|
|
|
|
serial.closeComm();
|
|
|
+
|
|
|
+ m_is_xunichuangkou_working = false;
|
|
|
}
|
|
|
|
|
|
void CValueWnd::WatchWnd()
|
|
|
{
|
|
|
+ m_is_chuangkou_working = true;
|
|
|
+
|
|
|
std::string system_setting_jinezhuaqu_setting_chuangkou_process_name = CSetting::GetParam("system_setting_jinezhuaqu_setting_chuangkou_process_name");
|
|
|
std::string system_setting_jinezhuaqu_setting_chuangkou_title = CSetting::GetParam("system_setting_jinezhuaqu_setting_chuangkou_title");
|
|
|
std::string system_setting_jinezhuaqu_setting_chuangkou_zorder = CSetting::GetParam("system_setting_jinezhuaqu_setting_chuangkou_zorder");
|
|
|
@@ -292,10 +303,14 @@ void CValueWnd::WatchWnd()
|
|
|
|
|
|
Sleep(200);
|
|
|
}
|
|
|
+
|
|
|
+ m_is_chuangkou_working = false;
|
|
|
}
|
|
|
|
|
|
void CValueWnd::StartOcrWork()
|
|
|
{
|
|
|
+ m_is_orc_working = true;
|
|
|
+
|
|
|
int system_setting_jinezhuaqu_setting_ocr_left = atoi(CSetting::GetParam("system_setting_jinezhuaqu_setting_ocr_left").c_str());
|
|
|
int system_setting_jinezhuaqu_setting_ocr_top = atoi(CSetting::GetParam("system_setting_jinezhuaqu_setting_ocr_top").c_str());
|
|
|
int system_setting_jinezhuaqu_setting_ocr_right = atoi(CSetting::GetParam("system_setting_jinezhuaqu_setting_ocr_right").c_str());
|
|
|
@@ -346,6 +361,8 @@ void CValueWnd::StartOcrWork()
|
|
|
|
|
|
Sleep(200);
|
|
|
}
|
|
|
+
|
|
|
+ m_is_orc_working = false;
|
|
|
}
|
|
|
|
|
|
LRESULT CValueWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
@@ -387,13 +404,6 @@ LRESULT CValueWnd::OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl
|
|
|
**/
|
|
|
LRESULT CValueWnd::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
{
|
|
|
- Shell_NotifyIcon(NIM_DELETE, &m_trayIcon);
|
|
|
-
|
|
|
- UnregisterHotKey(m_hWnd, WM_MYHOTKEY_SHOUKUAN);
|
|
|
-
|
|
|
- //注意这里不能delete,这个对象会delete自己
|
|
|
- m_push->Stop();
|
|
|
-
|
|
|
bHandled = FALSE;
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -889,8 +899,6 @@ void CValueWnd::ShowSystemSetting()
|
|
|
pSystemSettingFrame->CenterWindow();
|
|
|
UINT ret = pSystemSettingFrame->ShowModal();
|
|
|
|
|
|
- m_is_show_setting = false;
|
|
|
-
|
|
|
if (ret == IDOK)
|
|
|
{
|
|
|
|
|
|
@@ -899,6 +907,23 @@ void CValueWnd::ShowSystemSetting()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ if (pSystemSettingFrame->m_is_logout)
|
|
|
+ {
|
|
|
+ //这个表示是通过退出登录关闭的
|
|
|
+
|
|
|
+ delete pSystemSettingFrame;
|
|
|
+
|
|
|
+ Logout();
|
|
|
+
|
|
|
+ int a = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ delete pSystemSettingFrame;
|
|
|
+
|
|
|
+ m_is_show_setting = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1012,6 +1037,66 @@ void CValueWnd::ShowJiaoban()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void CValueWnd::Logout()
|
|
|
+{
|
|
|
+ //先做一些清理工作
|
|
|
+
|
|
|
+ m_is_quit = true;
|
|
|
+
|
|
|
+ //取消注册的快捷键
|
|
|
+ UnregisterHotKey(m_hWnd, WM_MYHOTKEY_SHOUKUAN);
|
|
|
+
|
|
|
+ //删除右下角的托盘
|
|
|
+ Shell_NotifyIcon(NIM_DELETE, &m_trayIcon);
|
|
|
+
|
|
|
+ //注意这里不能delete,这个对象会delete自己
|
|
|
+ m_push->Stop();
|
|
|
+ delete m_push;
|
|
|
+
|
|
|
+ pMenu->Close();
|
|
|
+ delete pMenu;
|
|
|
+
|
|
|
+ pDingweiWnd->Close();
|
|
|
+ delete pDingweiWnd;
|
|
|
+
|
|
|
+ pDingweiInfoWnd->Close();
|
|
|
+ delete pDingweiInfoWnd;
|
|
|
+
|
|
|
+ pOcrWnd->Close();
|
|
|
+ delete pOcrWnd;
|
|
|
+
|
|
|
+ //注销Hook
|
|
|
+ UninstallHook();
|
|
|
+
|
|
|
+ //暂停数据监控
|
|
|
+ StopWatch();
|
|
|
+
|
|
|
+ CSetting::SetParam("setting_is_auto_login", "0", true);
|
|
|
+ CLoginWnd* pLogin = new CLoginWnd();
|
|
|
+
|
|
|
+ if (pLogin == NULL)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置模式
|
|
|
+ pLogin->Create(NULL, _T("智铺子收银插件登录"), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW, 0, 0, 0, 0, NULL);
|
|
|
+ pLogin->SetIcon(IDI_ICON_DUILIB);
|
|
|
+ pLogin->CenterWindow();
|
|
|
+
|
|
|
+ ::ShowWindow(*pLogin, SW_SHOWNORMAL);
|
|
|
+
|
|
|
+ Close();
|
|
|
+
|
|
|
+ int a = 1;
|
|
|
+}
|
|
|
+
|
|
|
+void CValueWnd::QuitApp()
|
|
|
+{
|
|
|
+ //直接退出整个程序
|
|
|
+ PostQuitMessage(0);
|
|
|
+}
|
|
|
+
|
|
|
void CValueWnd::UpdateKexian(const char* data, int length)
|
|
|
{
|
|
|
std::string new_data = data;
|
|
|
@@ -1347,6 +1432,20 @@ bool CValueWnd::UpdateRegisterHotKey()
|
|
|
return nRet;
|
|
|
}
|
|
|
|
|
|
+//全局监听键盘输入
|
|
|
+void CValueWnd::RegKeyboardRawInput()
|
|
|
+{
|
|
|
+ RAWINPUTDEVICE rawInputDevice[1];
|
|
|
+ rawInputDevice[0].usUsagePage = 0x01;//设备类
|
|
|
+ rawInputDevice[0].usUsage = 0x06;//设备类内的具体设备
|
|
|
+ rawInputDevice[0].dwFlags = RIDEV_INPUTSINK;//意味着即使窗口失去焦点位置,仍然会一直接收输入消息
|
|
|
+ rawInputDevice[0].hwndTarget = m_hWnd;
|
|
|
+ if (RegisterRawInputDevices(rawInputDevice, 1, sizeof(rawInputDevice[0])) == FALSE)
|
|
|
+ {
|
|
|
+ printf("RegisterRawInputDevices failed");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void CValueWnd::PrintTest()
|
|
|
{
|
|
|
m_push->AddPrinter("", 3);
|