This commit is contained in:
2013-07-20 23:23:04 +00:00
parent bfb69b3898
commit 5dec3856be

View File

@@ -0,0 +1,286 @@
// FindTargetWndDlg.cpp : implementation file
//
#include "stdafx.h"
#include "HookMsg.h"
#include "FindTargetWndDlg.h"
#include <afxctl.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFindTargetWndDlg dialog
CFindTargetWndDlg::CFindTargetWndDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFindTargetWndDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFindTargetWndDlg)
//}}AFX_DATA_INIT
for( int i=0; i<MAX_FIND; i++ )
m_hFindWindow[i] = NULL;
m_bFinding = FALSE;
m_hLastFind = NULL;
m_nFindNow = -1;
m_idHANDLE = IDC_H_HANDLE_STATIC1;
m_idCAPTION = IDC_H_CAPTION_STATIC1;
m_idCLASS = IDC_H_CLASS_STATIC1;
}
void CFindTargetWndDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFindTargetWndDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFindTargetWndDlg, CDialog)
//{{AFX_MSG_MAP(CFindTargetWndDlg)
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONUP()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFindTargetWndDlg message handlers
BOOL CFindTargetWndDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ModifyStyleEx(NULL, WS_EX_TOPMOST);
RECT rect ;
GetWindowRect(&rect) ;
MoveWindow( 0, 200, rect.right-rect.left, rect.bottom-rect.top) ;
CWnd* pWnd = (CWnd*)GetDlgItem(IDC_ACTION_PICTURE);
pWnd->ShowWindow(FALSE);
if( ::IsWindow(m_hFindWindow[0]) )
SetDlgItemText( IDC_H_HANDLE_STATIC1, "유효합니다." );
else
SetDlgItemText( IDC_H_HANDLE_STATIC1, "<미지정>" );
if( ::IsWindow(m_hFindWindow[1]) )
SetDlgItemText( IDC_H_HANDLE_STATIC2, "유효합니다." );
else
SetDlgItemText( IDC_H_HANDLE_STATIC2, "<미지정>" );
if( ::IsWindow(m_hFindWindow[2]) )
SetDlgItemText( IDC_H_HANDLE_STATIC3, "유효합니다." );
else
SetDlgItemText( IDC_H_HANDLE_STATIC3, "<미지정>." );
if( ::IsWindow(m_hFindWindow[3]) )
SetDlgItemText( IDC_H_HANDLE_STATIC4, "유효합니다." );
else
SetDlgItemText( IDC_H_HANDLE_STATIC4, "<미지정>" );
if( ::IsWindow(m_hFindWindow[4]) )
SetDlgItemText( IDC_H_HANDLE_STATIC5, "유효합니다." );
else
SetDlgItemText( IDC_H_HANDLE_STATIC5, "<미지정>" );
if( ::IsWindow(m_hFindWindow[5]) )
SetDlgItemText( IDC_H_HANDLE_STATIC6, "유효합니다." );
else
SetDlgItemText( IDC_H_HANDLE_STATIC6, "<미지정>" );
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFindTargetWndDlg::OnOK()
{
CDialog::OnOK();
}
void CFindTargetWndDlg::OnCancel()
{
CDialog::OnCancel();
}
void CFindTargetWndDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CRect rcFindWnd[ MAX_FIND ];
GetDlgItem(IDC_H_PICTURE1)->GetWindowRect(rcFindWnd[0]);
ScreenToClient(rcFindWnd[0]);
GetDlgItem(IDC_H_PICTURE2)->GetWindowRect(rcFindWnd[1]);
ScreenToClient(rcFindWnd[1]);
GetDlgItem(IDC_H_PICTURE3)->GetWindowRect(rcFindWnd[2]);
ScreenToClient(rcFindWnd[2]);
GetDlgItem(IDC_H_PICTURE4)->GetWindowRect(rcFindWnd[3]);
ScreenToClient(rcFindWnd[3]);
GetDlgItem(IDC_H_PICTURE5)->GetWindowRect(rcFindWnd[4]);
ScreenToClient(rcFindWnd[4]);
GetDlgItem(IDC_H_PICTURE6)->GetWindowRect(rcFindWnd[5]);
ScreenToClient(rcFindWnd[5]);
CWnd* pActPic = (CWnd*)GetDlgItem(IDC_ACTION_PICTURE);
if (m_bFinding == FALSE)
{
if( rcFindWnd[0].PtInRect(point) == TRUE)
{
m_nFindNow = 0; m_hFindWindow[0] = NULL;
m_idHANDLE = IDC_H_HANDLE_STATIC1;
m_idCAPTION = IDC_H_CAPTION_STATIC1;
m_idCLASS = IDC_H_CLASS_STATIC1;
pActPic->MoveWindow(rcFindWnd[0]);
}
else if( rcFindWnd[1].PtInRect(point) == TRUE)
{
m_nFindNow = 1; m_hFindWindow[1] = NULL;
m_idHANDLE = IDC_H_HANDLE_STATIC2;
m_idCAPTION = IDC_H_CAPTION_STATIC2;
m_idCLASS = IDC_H_CLASS_STATIC2;
pActPic->MoveWindow(rcFindWnd[1]);
}
else if( rcFindWnd[2].PtInRect(point) == TRUE)
{
m_nFindNow = 2; m_hFindWindow[2] = NULL;
m_idHANDLE = IDC_H_HANDLE_STATIC3;
m_idCAPTION = IDC_H_CAPTION_STATIC3;
m_idCLASS = IDC_H_CLASS_STATIC3;
pActPic->MoveWindow(rcFindWnd[2]);
}
else if( rcFindWnd[3].PtInRect(point) == TRUE)
{
m_nFindNow = 3; m_hFindWindow[3] = NULL;
m_idHANDLE = IDC_H_HANDLE_STATIC4;
m_idCAPTION = IDC_H_CAPTION_STATIC4;
m_idCLASS = IDC_H_CLASS_STATIC4;
pActPic->MoveWindow(rcFindWnd[3]);
}
else if( rcFindWnd[4].PtInRect(point) == TRUE)
{
m_nFindNow = 4; m_hFindWindow[4] = NULL;
m_idHANDLE = IDC_H_HANDLE_STATIC5;
m_idCAPTION = IDC_H_CAPTION_STATIC5;
m_idCLASS = IDC_H_CLASS_STATIC5;
pActPic->MoveWindow(rcFindWnd[4]);
}
else if( rcFindWnd[5].PtInRect(point) == TRUE)
{
m_nFindNow = 5; m_hFindWindow[5] = NULL;
m_idHANDLE = IDC_H_HANDLE_STATIC6;
m_idCAPTION = IDC_H_CAPTION_STATIC6;
m_idCLASS = IDC_H_CLASS_STATIC6;
pActPic->MoveWindow(rcFindWnd[5]);
}
else
{
CDialog::OnLButtonDown(nFlags, point);
return;
}
SetDlgItemText(m_idHANDLE, "Finding...");
SetDlgItemText(m_idCAPTION, "");
SetDlgItemText(m_idCLASS, "");
pActPic->ShowWindow( TRUE );
m_bFinding = TRUE;
m_hLastFind = NULL;
SetCapture();
}
CDialog::OnLButtonDown(nFlags, point);
}
void CFindTargetWndDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
if (m_bFinding) {
CWnd* pActPic = (CWnd*)GetDlgItem(IDC_ACTION_PICTURE);
pActPic->ShowWindow( FALSE );
m_bFinding = FALSE;
ReleaseCapture();
if (m_hLastFind) DrawBorder(m_hLastFind);
}
CDialog::OnLButtonUp(nFlags, point);
}
void CFindTargetWndDlg::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_bFinding) {
SetCursor(AfxGetApp()->LoadCursor(IDC_FINDCURSOR));
CPoint pt = point;
ClientToScreen(&pt);
CWnd* pWnd = CWnd::WindowFromPoint(pt);
if (pWnd && pWnd != this && pWnd != this->GetParent())
{
CString strClass;
::GetClassName(pWnd->GetSafeHwnd(), strClass.GetBuffer(256), 256);
strClass.ReleaseBuffer();
if( strClass==_T("SysTabControl32") ||
(strClass==_T("Button") && pWnd->GetStyle() & BS_GROUPBOX) )
{
pWnd->SetWindowPos( &wndBottom, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOREDRAW );
CWnd *pWnd2 = CWnd::WindowFromPoint(pt);
if( pWnd2 )
{
UpdateEditBox(pWnd2, TRUE);
}
CDialog::OnMouseMove(nFlags, point);
return;
}
UpdateEditBox(pWnd, TRUE);
}
}
CDialog::OnMouseMove(nFlags, point);
}
void CFindTargetWndDlg::UpdateEditBox(CWnd* pWnd, BOOL bDrawBorder)
{
if (m_hLastFind == pWnd->GetSafeHwnd()) return;
if (m_hLastFind) DrawBorder(m_hLastFind);
if (bDrawBorder) DrawBorder(pWnd->GetSafeHwnd());
m_hFindWindow[ m_nFindNow ] = m_hLastFind = pWnd->GetSafeHwnd();
CString strHandle;
strHandle.Format(_T("0x%08x"), pWnd->GetSafeHwnd());
CString strCaption;
pWnd->GetWindowText(strCaption);
CString strClass;
::GetClassName(pWnd->GetSafeHwnd(), strClass.GetBuffer(256), 256);
strClass.ReleaseBuffer();
SetDlgItemText(m_idHANDLE, strHandle);
SetDlgItemText(m_idCAPTION, strCaption);
SetDlgItemText(m_idCLASS, strClass);
}
void CFindTargetWndDlg::DrawBorder(HWND hWnd)
{
HDC hDC = ::GetWindowDC(hWnd);
int nOldROP = ::SetROP2(hDC, R2_NOT);
CRect rect;
::GetWindowRect(hWnd, &rect);
rect.OffsetRect(-rect.left, -rect.top);
for (int i=0; i<3; i++) {
::MoveToEx(hDC, rect.left, rect.top, NULL);
::LineTo( hDC, rect.right, rect.top);
::LineTo( hDC, rect.right, rect.bottom);
::LineTo( hDC, rect.left, rect.bottom);
::LineTo( hDC, rect.left, rect.top);
rect.DeflateRect(1,1,1,1);
}
::SetROP2(hDC, nOldROP);
::ReleaseDC(hWnd, hDC);
}