Przeglądaj źródła

退出登录的功能调整好了

zhangyang 5 lat temu
rodzic
commit
ddb4fd2a8b

BIN
lib/debug/zpzDll.lib


+ 2 - 0
zhipuzi_pay_plugin/network/CMessagePush.cpp

@@ -27,6 +27,8 @@ void CMessagePush::Stop()
 	{
 		Sleep(100);
 	}
+
+	delete this;
 }
 
 void CMessagePush::AddPrinter(std::string out_order_no, int print_type)

+ 2 - 2
zhipuzi_pay_plugin/wnd/CDingweiInfoWnd.h

@@ -21,8 +21,8 @@ public:
 
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
-		//m_pm.RemovePreMessageFilter(this);
-		//delete this;
+		m_pm.RemovePreMessageFilter(this);
+		delete this;
 	};
 
 	void Init();

+ 2 - 2
zhipuzi_pay_plugin/wnd/CDingweiWnd.h

@@ -18,8 +18,8 @@ public:
 
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
-		//m_pm.RemovePreMessageFilter(this);
-		//delete this;
+		m_pm.RemovePreMessageFilter(this);
+		delete this;
 	};
 
 	void Init();

+ 41 - 0
zhipuzi_pay_plugin/wnd/CHttpProxySettingWnd.cpp

@@ -3,6 +3,9 @@
 
 void CHttpProxySettingWnd::Init()
 {
+	//ĆÁÄťžÓÖĐ
+	InitWndPos();
+
 	CCheckBoxUI* is_http_proxy = static_cast<CCheckBoxUI*>(m_pm.FindControl(L"http_proxy_setting_wnd_isdaili"));
 	std::string http_is_proxy = CSetting::GetParam("http_is_proxy");
 	if (http_is_proxy == "1")
@@ -173,6 +176,44 @@ LRESULT CHttpProxySettingWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lP
 	return false;
 }
 
+void CHttpProxySettingWnd::InitWndPos()
+{
+	ASSERT(::IsWindow(m_hWnd));
+	ASSERT((GetWindowStyle(m_hWnd)&WS_CHILD) == 0);
+
+	RECT rcDlg = { 0 };
+	::GetWindowRect(m_hWnd, &rcDlg);
+
+	int DlgWidth = rcDlg.right - rcDlg.left;
+	int DlgHeight = rcDlg.bottom - rcDlg.top;
+
+	RECT rcArea = { 0 };
+	::GetWindowRect(::GetDesktopWindow(), &rcArea);	
+
+	int xLeft = (rcArea.right - DlgWidth) / 2;
+	int yTop = (rcArea.bottom - DlgHeight) / 2;
+
+	if (xLeft < rcArea.left)
+	{
+		xLeft = rcArea.left;
+	}
+	else if (xLeft + DlgWidth > rcArea.right)
+	{
+		xLeft = rcArea.right - DlgWidth;
+	}
+
+	if (yTop < rcArea.top)
+	{
+		yTop = rcArea.top;
+	}
+	else if (yTop + DlgHeight > rcArea.bottom)
+	{
+		yTop = rcArea.bottom - DlgHeight;
+	}
+
+	::SetWindowPos(m_hWnd, HWND_TOPMOST, xLeft, yTop, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
+}
+
 
 
 

+ 2 - 1
zhipuzi_pay_plugin/wnd/CHttpProxySettingWnd.h

@@ -17,7 +17,6 @@ public:
 
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
-		//WindowImplBase::OnFinalMessage(hWnd);
 		m_pm.RemovePreMessageFilter(this);
 
 		delete this;
@@ -81,6 +80,8 @@ public:
 
 	LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
 
+	void InitWndPos();
+
 public:
 	CPaintManagerUI m_pm;
 };

+ 0 - 1
zhipuzi_pay_plugin/wnd/CJiaobanWnd.h

@@ -28,7 +28,6 @@ public:
 
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
-		//WindowImplBase::OnFinalMessage(hWnd);
 		m_pm.RemovePreMessageFilter(this);
 		delete this;
 	};

+ 0 - 1
zhipuzi_pay_plugin/wnd/CJiaoyihuizongWnd.h

@@ -26,7 +26,6 @@ public:
 
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
-		//WindowImplBase::OnFinalMessage(hWnd);
 		m_pm.RemovePreMessageFilter(this);
 		delete this;
 	};

+ 0 - 1
zhipuzi_pay_plugin/wnd/CJiaoyijiluWnd.h

@@ -26,7 +26,6 @@ public:
 
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
-		//WindowImplBase::OnFinalMessage(hWnd);
 		m_pm.RemovePreMessageFilter(this);
 		delete this;
 	};

+ 7 - 12
zhipuzi_pay_plugin/wnd/CLoginWnd.cpp

@@ -9,6 +9,9 @@
 
 void CLoginWnd::Init()
 {
+	//窗口置顶
+	::SetWindowPos(m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+
     CLabelUI* version = static_cast<CLabelUI*>(m_pm.FindControl(_T("login_version")));
     version->SetText((L"智铺子收银插件 " + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion())).c_str());
 
@@ -117,18 +120,10 @@ void CLoginWnd::Notify(TNotifyUI& msg)
         }
 		else if (msg.pSender->GetName() == L"proxy_setting")
 		{
-			CHttpProxySettingWnd* pWaimaiFailFrame = new CHttpProxySettingWnd();
-			pWaimaiFailFrame->Create(NULL, _T("网络代理设置"), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
-			pWaimaiFailFrame->SetIcon(IDI_ICON_DUILIB);
-			pWaimaiFailFrame->CenterWindow();
-			UINT ret = pWaimaiFailFrame->ShowModal();
-
-			if (ret == IDOK)
-			{
-				//不用处理,在窗口函数已经处理
-			}
-
-			//不用delete窗口对象,窗口销毁的时候回自动delte
+			CHttpProxySettingWnd* pHttpProxySettingWnd = new CHttpProxySettingWnd();
+			pHttpProxySettingWnd->Create(m_hWnd, _T("网络代理设置"), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
+			pHttpProxySettingWnd->SetIcon(IDI_ICON_DUILIB);
+			pHttpProxySettingWnd->ShowModal();
 		}
     }
     else if(msg.sType == _T("itemselect"))

+ 1 - 1
zhipuzi_pay_plugin/wnd/CMenuWnd.h

@@ -21,7 +21,7 @@ public:
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
 		m_pm.RemovePreMessageFilter(this);
-		//delete this;
+		delete this;
 	};
 
 	void Init();

+ 1 - 2
zhipuzi_pay_plugin/wnd/CMessageboxWnd.h

@@ -17,10 +17,9 @@ public:
 
     void OnFinalMessage(HWND /*hWnd*/)
     {
-        //WindowImplBase::OnFinalMessage(hWnd);
         m_pm.RemovePreMessageFilter(this);
 
-        //delete this;
+        delete this;
     };
 
     void Init()

+ 2 - 2
zhipuzi_pay_plugin/wnd/COcrWnd.h

@@ -20,8 +20,8 @@ public:
 
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
-		//m_pm.RemovePreMessageFilter(this);
-		//delete this;
+		m_pm.RemovePreMessageFilter(this);
+		delete this;
 	};
 
 	void Init();

+ 1 - 1
zhipuzi_pay_plugin/wnd/CShoukuanWnd.h

@@ -24,7 +24,7 @@ public:
 
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
-		//m_pm.RemovePreMessageFilter(this);
+		m_pm.RemovePreMessageFilter(this);
 		delete this;
 	};
 

+ 3 - 8
zhipuzi_pay_plugin/wnd/CSystemSettingWnd.cpp

@@ -715,7 +715,8 @@ void CSystemSettingWnd::HandleClickMsg(TNotifyUI& msg)
 
     if(senderName == _T("system_setting_closebtn"))
     {
-        Close(IDCANCEL);
+		m_valueWnd->CloseSystemSetting();
+
         return;
     }
     else if(senderName == _T("jinezhuaqu_setting_chuangkou_select_value_search"))
@@ -989,13 +990,7 @@ void CSystemSettingWnd::HandleClickMsg(TNotifyUI& msg)
     }
 	else if (senderName == L"system_setting_logout")
 	{
-		//退出登录
-		m_is_logout = true;
-
-		Close(IDCANCEL);
-
-		int a = 1;
-		return;
+		m_valueWnd->Logout();
 	}
 }
 

+ 1 - 6
zhipuzi_pay_plugin/wnd/CSystemSettingWnd.h

@@ -26,11 +26,9 @@ public:
 
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
-		//WindowImplBase::OnFinalMessage(hWnd);
 		m_pm.RemovePreMessageFilter(this);
 
-		//这里不要调用delte,后面手动delete,如果自动delete了,窗口关闭后的逻辑不好处理
-		//delete this;
+		delete this;
 	};
 
 	void Init();
@@ -85,9 +83,6 @@ private:
 public:
 	CPaintManagerUI m_pm;
 
-	//表示是否是通过退出登录关闭的
-	bool m_is_logout = false;
-
 private:
 	CValueWnd* m_valueWnd;
 

+ 1 - 1
zhipuzi_pay_plugin/wnd/CTuikuanWnd.h

@@ -24,7 +24,7 @@ public:
 
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
-		//m_pm.RemovePreMessageFilter(this);
+		m_pm.RemovePreMessageFilter(this);
 		delete this;
 	};
 

+ 1 - 1
zhipuzi_pay_plugin/wnd/CUpdateWnd.h

@@ -20,7 +20,7 @@ public:
 
     void OnFinalMessage(HWND /*hWnd*/)
     {
-        //m_pm.RemovePreMessageFilter(this);
+        m_pm.RemovePreMessageFilter(this);
         delete this;
     };
 

+ 52 - 76
zhipuzi_pay_plugin/wnd/CValueWnd.cpp

@@ -2,15 +2,10 @@
 #include "CValueWnd.h"
 
 #include "../tool/CComHelper.h"
-
 #include "../tool/CSerialPort.h"
-
 #include "../helper/CBitmapHelper.h"
-
 #include "../network/CMessagePush.h"
 
-#include <atltypes.h>
-
 #include "CLoginWnd.h"
 
 void CValueWnd::Notify(TNotifyUI& msg)
@@ -897,36 +892,16 @@ void CValueWnd::ShowSystemSetting()
 		pSystemSettingFrame->Create(NULL, _T(""), UI_WNDSTYLE_DIALOG, WS_EX_TOOLWINDOW);
 		pSystemSettingFrame->SetIcon(IDI_ICON_DUILIB);
 		pSystemSettingFrame->CenterWindow();
-		UINT ret = pSystemSettingFrame->ShowModal();
-
-		int a = 1;
-
-		if (ret == IDOK)
-		{
-
-		}
-		else if (ret == IDCANCEL)
-		{
-
-		}
-
-		if (pSystemSettingFrame->m_is_logout)
-		{
-			//这个表示是通过退出登录关闭的
-
-			delete pSystemSettingFrame;
-
-			Logout();
+		pSystemSettingFrame->ShowWindow(true);
+	}
+}
 
-			int a = 1;
-		}
-		else
-		{
-			delete pSystemSettingFrame;
+void CValueWnd::CloseSystemSetting()
+{
+	m_is_show_setting = false;
 
-			m_is_show_setting = false;
-		}
-	}
+	m_settingWnd->Close();
+	m_settingWnd = NULL;
 }
 
 void CValueWnd::ShowJiaoyijilu()
@@ -1041,8 +1016,12 @@ void CValueWnd::ShowJiaoban()
 
 void CValueWnd::Logout()
 {
-	//先做一些清理工作
+	//先正常关闭设置窗口
+	m_is_show_setting = false;
+	m_settingWnd->Close();
+	m_settingWnd = NULL;
 
+	//先做一些清理工作
 	m_is_quit = true;
 
 	//取消注册的快捷键
@@ -1053,19 +1032,14 @@ void CValueWnd::Logout()
 
 	//注意这里不能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();
@@ -1073,30 +1047,53 @@ void CValueWnd::Logout()
 	//暂停数据监控
 	StopWatch();
 
+	this->Close();
+
+	//退出登录,取消自动登录
 	CSetting::SetParam("setting_is_auto_login", "0", true);
-	CLoginWnd* pLogin = new CLoginWnd();
 
+	//创建登录窗口
+	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;
+	pLogin->ShowWindow(true);
 }
 
 void CValueWnd::QuitApp()
 {
+	//先做一些清理工作
+	m_is_quit = true;
+
+	//取消注册的快捷键
+	UnregisterHotKey(m_hWnd, WM_MYHOTKEY_SHOUKUAN);
+
+	//删除右下角的托盘
+	Shell_NotifyIcon(NIM_DELETE, &m_trayIcon);
+
+	//注意这里不能delete,这个对象会delete自己
+	m_push->Stop();
+
 	pMenu->Close();
 
+	pDingweiWnd->Close();
+
+	pDingweiInfoWnd->Close();
+
+	pOcrWnd->Close();
+
+	//注销Hook
+	UninstallHook();
+
+	//暂停数据监控
+	StopWatch();
+
 	this->Close();
 
 	//直接退出整个程序
@@ -1214,40 +1211,19 @@ void CValueWnd::UpdateKexian(const char* data, int length)
 
 void CValueWnd::InitWndPos()
 {
-    ASSERT(::IsWindow(m_hWnd));
-    ASSERT((GetWindowStyle(m_hWnd)&WS_CHILD) == 0);
-    RECT rcDlg = { 0 };
-    ::GetWindowRect(m_hWnd, &rcDlg);
-    RECT rcArea = { 0 };
-    RECT rcCenter = { 0 };
-    HWND hWnd = *this;
-    HWND hWndParent = ::GetParent(m_hWnd);
-    HWND hWndCenter = ::GetWindowOwner(m_hWnd);
-
-    if(hWndCenter != NULL)
-    {
-        hWnd = hWndCenter;
-    }
+	ASSERT(::IsWindow(m_hWnd));
+	ASSERT((GetWindowStyle(m_hWnd)&WS_CHILD) == 0);
 
-    // 处理多显示器模式下屏幕居中
-    MONITORINFO oMonitor = {};
-    oMonitor.cbSize = sizeof(oMonitor);
-    ::GetMonitorInfo(::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST), &oMonitor);
-    rcArea = oMonitor.rcWork;
+	RECT rcDlg = { 0 };
+	::GetWindowRect(m_hWnd, &rcDlg);
 
-    if(hWndCenter == NULL)
-    {
-        rcCenter = rcArea;
-    }
-    else
-    {
-        ::GetWindowRect(hWndCenter, &rcCenter);
-    }
+	int DlgWidth = rcDlg.right - rcDlg.left;
+	int DlgHeight = rcDlg.bottom - rcDlg.top;
 
-    int DlgWidth = rcDlg.right - rcDlg.left;
-    int DlgHeight = rcDlg.bottom - rcDlg.top;
+	RECT rcArea = { 0 };
+	::GetWindowRect(::GetDesktopWindow(), &rcArea);
 
-    int xLeft = rcCenter.right - DlgWidth - 60;
+    int xLeft = rcArea.right - DlgWidth - 60;
     int yTop = 100;
 
     if(xLeft < rcArea.left)

+ 3 - 0
zhipuzi_pay_plugin/wnd/CValueWnd.h

@@ -92,6 +92,9 @@ public:
 	//显示设置页面
 	void ShowSystemSetting();
 
+	//关闭设置页面
+	void CloseSystemSetting();
+
 	//显示交易记录页面
 	void ShowJiaoyijilu();