Browse Source

使用WM_NCLBUTTONDOWN、WM_NCLBUTTONUP、WM_NCMOUSEMOVE组合消息来获取宿主窗口的移动过程,用来移动微信阴影窗口:未完成。

Jeff 6 years ago
parent
commit
e08e157924

+ 0 - 9
source/hook/WeChats/CWxObject.cpp

@@ -283,15 +283,6 @@ BOOL CWxObject::Attach2MainWnd(CWnd *pMainWnd, BOOL bLoginWnd )
 			::MoveWindow(hWxWnd, rcDisplay.left, rcDisplay.top, rcDisplay.Width(), rcDisplay.Height(), true);
 			//::SetWindowPos(hWxWnd, NULL, rcDisplay.left, rcDisplay.top, rcDisplay.Width(), rcDisplay.Height(), WM_MOVE| WM_SIZE| WM_WINDOWPOSCHANGING| WM_NCCALCSIZE | SWP_SHOWWINDOW);
 		}
-
-#ifdef _DEBUG
-		pMainWnd->ClientToScreen(&rect);
-		WriteTextLog(_T("rect=[%d,%d,%d,%d]"), rect.left, rect.top, rect.right, rect.bottom);
-		//pMainWnd->ScreenToClient(&m_rcWxWnd);
-		WriteTextLog(_T("m_rcWxWnd=[%d,%d,%d,%d]"), m_rcWxWnd.left, m_rcWxWnd.top, m_rcWxWnd.right, m_rcWxWnd.bottom);
-		WriteTextLog(_T("rcCenter=[%d,%d,%d,%d]"), rcDisplay.left, rcDisplay.top, rcDisplay.right, rcDisplay.bottom);
-#endif
-
 		
 		//窗口重绘,(因创建exe时,设置为SW_HIDE,导致exe窗口会被父窗口覆盖一部分)
 		pMainWnd->Invalidate();

+ 1 - 1
source/hook/WeChats/Global.cpp

@@ -58,7 +58,7 @@ int GetIniInfo(LPCTSTR lpIniDir /* = NULL */, LPCTSTR lpIniName /* = NULL */)
 	_stprintf_s(g_szDynamicLibraryPath, _T("%shook.dll"), g_szModulePath);
 #ifdef _DEBUG
 	_stprintf_s(g_szDynamicLibraryPath, _T("%shook.dll"), _T("E:\\bin\\WeChats2017\\"));
-	WriteTextLog(g_szDynamicLibraryPath);
+	WriteTextLog(_T("DLL·¾¶=%s"),g_szDynamicLibraryPath);
 #endif
 
 	if (lpIniDir != NULL && lpIniName != NULL)

+ 1 - 1
source/hook/WeChats/WeChats.vcxproj

@@ -101,7 +101,7 @@
       <PrecompiledHeader>Use</PrecompiledHeader>
       <WarningLevel>Level3</WarningLevel>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
-      <AdditionalIncludeDirectories>..\Include</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>..\Include;..\skinui</AdditionalIncludeDirectories>
     </ClCompile>
     <ResourceCompile>
       <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>

+ 35 - 4
source/hook/WeChats/WeChatsDlg.cpp

@@ -51,6 +51,7 @@ HWND g_hWxWnd = NULL;
 CWeChatsDlg::CWeChatsDlg(CWnd* pParent /*=NULL*/)
 	: CDialog(CWeChatsDlg::IDD, pParent)
 {
+	m_bMouseDown = FALSE;
 	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
 }
 
@@ -168,7 +169,6 @@ void CWeChatsDlg::OnBnClickedOpenWx()
 {
 	// TODO: 在此添加控件通知处理程序代码
 
-#ifdef _DEBUG
 	//vector<DWORD> vtPID = FindAllProcess(_T("lyfzServer.exe"));
 	vector<DWORD> vtPID = FindAllProcess(WECHAT);
 	//vector<DWORD> vtPID = FindAllProcess(_T("cheatengine-x86_64.exe"));
@@ -183,7 +183,6 @@ void CWeChatsDlg::OnBnClickedOpenWx()
 			m_wxObj.Attach2MainWnd(GetDlgItem(WX_RECT), FALSE);
 		}
 	}
-#endif
 }
 
 
@@ -192,7 +191,7 @@ HBRUSH CWeChatsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
 	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
 
 	// TODO:  在此更改 DC 的任何特性
-	//pDC->SetBkMode(TRANSPARENT);
+	pDC->SetBkMode(TRANSPARENT);
 
 	// TODO:  如果默认的不是所需画笔,则返回另一个画笔
 	return hbr;
@@ -203,6 +202,38 @@ BOOL CWeChatsDlg::DestroyWindow()
 {
 	// TODO: 在此添加专用代码和/或调用基类
 	m_wxObj.DetachWxWnd();
-	//m_wxObj.EjectDynamicLibrary();
 	return CDialog::DestroyWindow();
 }
+
+
+BOOL CWeChatsDlg::PreTranslateMessage(MSG* pMsg)
+{
+	// TODO: 在此添加专用代码和/或调用基类
+	if (pMsg->hwnd == m_hWnd)
+	{
+		if (pMsg->message == WM_NCLBUTTONDOWN)
+		{// 非客户区左键按下;
+			m_bMouseDown = TRUE;
+		}
+
+		if (pMsg->message == WM_NCLBUTTONUP)
+		{// 非客户区左键放开;
+			m_bMouseDown = FALSE;
+		}
+
+		if (pMsg->message == WM_NCMOUSEMOVE)
+		{// 非客户区鼠标移动;
+			if (m_bMouseDown)
+			{
+				Invalidate();
+				::UpdateWindow(m_wxObj.m_hWxMainWnd);
+				::ShowWindow(m_wxObj.m_hWxMainWnd, SW_SHOW);
+				WriteTextLog(_T("移动时刷新窗口"));
+			}
+		}
+
+		//WriteTextLog(_T("窗口:%p, 消息:%d, LP:%d, WP:%d, 时间:%d"), pMsg->hwnd, pMsg->message, pMsg->lParam, pMsg->wParam, pMsg->time);
+	}
+	
+	return CDialog::PreTranslateMessage(pMsg);
+}

+ 4 - 1
source/hook/WeChats/WeChatsDlg.h

@@ -23,7 +23,9 @@ public:
 // 实现
 protected:
 	HICON m_hIcon;
-
+	// 是否拖动鼠标左键;
+	BOOL m_bMouseDown;
+	BOOL m_bMouseDrag;
 	// 生成的消息映射函数
 	virtual BOOL OnInitDialog();
 	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
@@ -35,4 +37,5 @@ public:
 	afx_msg void OnBnClickedOpenWx();
 	afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
 	virtual BOOL DestroyWindow();
+	virtual BOOL PreTranslateMessage(MSG* pMsg);
 };