FlagDlg.cpp
资源名称:CQQFind.rar [点击查看]
上传用户:cxh888fhc
上传日期:2017-07-08
资源大小:240k
文件大小:4k
源码类别:
钩子与API截获
开发平台:
Visual C++
- // FlagDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "CQQFind.h"
- #include "FlagDlg.h"
- #include "CQQFindDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CFlagDlg dialog
- #define DLL_IMPORT extern "C" __declspec(dllimport)
- DLL_IMPORT HHOOK SetFocusHook(HWND hWnd,DWORD dwThread);
- DWORD MOVEMSG=RegisterWindowMessage("MOVEMSG");
- CFlagDlg::CFlagDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CFlagDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CFlagDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CFlagDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CFlagDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CFlagDlg, CDialog)
- //{{AFX_MSG_MAP(CFlagDlg)
- ON_WM_PAINT()
- ON_WM_CLOSE()
- //}}AFX_MSG_MAP
- ON_REGISTERED_MESSAGE(MOVEMSG,OnMoveMsg)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CFlagDlg message handlers
- void CFlagDlg::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- // TODO: Add your message handler code here
- // Do not call CDialog::OnPaint() for painting messages
- int nCount=m_arrayDif.GetSize();
- int i;
- CBrush *pOldBrush=(CBrush *)dc.SelectStockObject(NULL_BRUSH);
- CPen pen;
- pen.CreatePen(PS_SOLID,((CCQQFindDlg *)GetParent())->m_nWidth,((CCQQFindDlg *)GetParent())->m_clrDraw);
- CPen *pOldPen=(CPen *)dc.SelectObject(&pen);
- for(i=0;i<nCount;i++)
- {
- RECT rcTemp;
- rcTemp=m_arrayDif.GetAt(i);
- if(((CCQQFindDlg *)GetParent())->m_bCircle==TRUE)
- {
- dc.Ellipse(&rcTemp);
- }
- else
- {
- dc.Rectangle(&rcTemp);
- }
- }
- dc.SelectObject(pOldPen);
- dc.SelectObject(pOldBrush);
- //依次画出所有的标识圆圈
- }
- BOOL CFlagDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- SetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE,
- GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)|0x80000);
- HINSTANCE hInst=LoadLibrary("User32.DLL");
- COLORREF bkColor = GetSysColor( COLOR_3DFACE );
- if(hInst)
- {
- typedef BOOL (WINAPI *MYFUNC)(HWND,COLORREF,BYTE,DWORD);
- MYFUNC fun = NULL;
- fun=(MYFUNC)GetProcAddress(hInst, "SetLayeredWindowAttributes");
- if(fun)fun(this->GetSafeHwnd(),bkColor,0,1);
- FreeLibrary(hInst);
- }
- //初始化对话框的时候设置其显示方式透明方式.
- HWND hWnd=::FindWindow("#32770","大家来找茬");
- if(hWnd!=NULL)
- {
- //初始显示时,和当前游戏窗口位置保持一致.
- RECT rcWindow;
- ::GetWindowRect(hWnd,&rcWindow);
- MoveWindow(rcWindow.left+m_rcRegion.left,rcWindow.top+m_rcRegion.top,
- m_rcRegion.right-m_rcRegion.left,m_rcRegion.bottom-m_rcRegion.top,FALSE);
- m_hHook=SetFocusHook(m_hWnd,GetWindowThreadProcessId(hWnd,NULL));
- }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- LRESULT CFlagDlg::OnMoveMsg(WPARAM wParam,LPARAM lParam)
- {
- //检测到目标游戏对话框移动,则及时移动以便保持同步
- int xPos = (int)(short) LOWORD(lParam); // horizontal position
- int yPos = (int)(short) HIWORD(lParam); // vertical position
- MoveWindow(m_rcRegion.left+xPos,m_rcRegion.top+yPos,
- m_rcRegion.right-m_rcRegion.left,m_rcRegion.bottom-m_rcRegion.top,FALSE);
- return 0L;
- }
- void CFlagDlg::OnClose()
- {
- // TODO: Add your message handler code here and/or call default
- UnhookWindowsHookEx(m_hHook);
- CDialog::OnClose();
- }