Esempio n. 1
0
void CMainDlg::OnMouseHookMouseMove(UINT nFlags, CPoint point)
{
	// TODO : figure out while cursor is not changing 
	// Change cursor
	::SetCursor(m_hSelectCursor);

	// Check selecting flag
	if(m_bSelecting)
	{
		// Get window under mouse
		HWND hFound = ::WindowFromPoint(point);
		if(m_hHilightWnd != hFound)
		{
			HWND hOld = m_hHilightWnd;
			m_hHilightWnd = hFound;

			// Undraw old
			if((hOld) && (::IsWindow(hOld)))
				RefreshWindow(hOld);

			// Draw new
			HighlightWindow(m_hHilightWnd);
		}
	}

	// Check drawing flag
	if(m_bDrawing)
	{
		// Draw 
		DrawFocusRect(point);

		// Save current point
		m_ptLast = point;
	}
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
// Name: MouseMove
// Object: should be call on a WM_LBUTTONUP or WM_KILLFOCUS message
// Parameters : 
// Return : TRUE if we were choosing a window
//-----------------------------------------------------------------------------
BOOL CSelectWindow::MouseUp()
{
    if(!this->bInitializeDone)
        return FALSE;

    if(!this->bCapture)
        return FALSE;
    
    if(this->hWndOld)
        HighlightWindow(this->hWndOld,FALSE);
    this->hWndOld = NULL;

    SetCursor( this->hCurNormal );
    SendMessage (this->hPictureBox,STM_SETIMAGE,IMAGE_BITMAP,(LONG)this->hBmpCross);
    ReleaseCapture();
    this->bCapture = FALSE;
    if (this->bMinimizeOwnerWindowWhenSelect)
        ShowWindow(this->hDlg,SW_RESTORE);
    
    return TRUE;
}
Esempio n. 3
0
LRESULT CALLBACK WindowProc( HWND wnd, DWORD msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {
        case WM_CREATE:
            break;
        case WM_DESTROY:
            PostQuitMessage( 0 );
            break;
        case WM_COMMAND:
            switch( wParam & 0xFFFF )
            {
                case REFRESH_ID:
                    if( wParam >> 16 == BN_CLICKED )
                    {
                        SendDlgItemMessage( wnd, TREE_ID, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT );
                        PopulateList( NULL, GetDesktopWindow(), GetDlgItem( wnd, TREE_ID ) );
                    }
                    break;
                case HIGHLIGHT_ID:
                    if( wParam >> 16 == BN_CLICKED )
                    {
                        if( current != NULL )
                        {
                            HighlightWindow( current, 0xFF0000 );
                        }
                    }
                    break;
                case PULL_ID:
                    if( wParam >> 16 == BN_CLICKED )
                    {
                        if( current != NULL )
                        {
                            SetForegroundWindow( current );
                        }
                    }
                    break;
                case DESTROY_ID:
                    if( wParam >> 16 == BN_CLICKED )
                    {
                        if( current != NULL )
                        {
                            SendMessage( current, WM_DESTROY, 0, 0 );
                        }
                    }
                    break;
                case CLOSE_ID:
                    if( wParam >> 16 == BN_CLICKED )
                    {
                        if( current != NULL )
                        {
                            SendMessage( current, WM_CLOSE, 0, 0 );
                        }
                    }
                    break;
                case KILLPROC_ID:
                    if( wParam >> 16 == BN_CLICKED )
                    {
                        if( current != NULL )
                        {
                            KillProcess( current, GetDlgItem( wnd, STATIC_ID ) );
                        }
                    }
                    break;
                case EDITMEM_ID:
                    if( wParam >> 16 == BN_CLICKED )
                    {
                        if( current != NULL )
                        {
                            EditProcMem( current, GetDlgItem( wnd, STATIC_ID ) );
                        }
                    }
                    break;
                case SHOW_ID:
                    if( wParam >> 16 == BN_CLICKED )
                    {
                        if( current != NULL )
                        {
                            ShowWindow( current, SW_SHOW );
                            UpdateWindow( current );
                        }
                    }
                    break;
                case HIDE_ID:
                    if( wParam >> 16 == BN_CLICKED )
                    {
                        if( current != NULL )
                        {
                            ShowWindow( current, SW_HIDE );
                            UpdateWindow( current );
                        }
                    }
                    break;
                case REDRAW_ID:
                    if( wParam >> 16 == BN_CLICKED )
                    {
                        if( current != NULL )
                        {
                            RedrawWindow( current, NULL, NULL, RDW_ERASE | RDW_INVALIDATE );
                            UpdateWindow( current );
                        }
                    }
                    break;
                default:
                    break;
            }
            break;
        case WM_NOTIFY:
            if( wParam == TREE_ID )
            {
                if( ((NM_TREEVIEW*)lParam)->hdr.code == TVN_SELCHANGED )
                {
                    current = (HWND)((NM_TREEVIEW*)lParam)->itemNew.lParam;
                    GetProcInfo( current, GetDlgItem( wnd, STATIC_ID ));
                }
            }
            break;
        default:
            return DefWindowProc( wnd, msg, wParam, lParam );
    }

    return 0;
}
Esempio n. 4
0
//-----------------------------------------------------------------------------
// Name: MouseMove
// Object: should be call on a WM_MOUSEMOVE message
// Parameters : 
//     in : POINT pt : mouse point in Screen reference
//     out : BOOL* pbWindowChanged : TRUE if selected window has changed
// Return : TRUE on success
//-----------------------------------------------------------------------------
BOOL CSelectWindow::MouseMove(POINT pt,BOOL* pbWindowChanged)
{
    HWND hWnd;
    HWND hWndTmp;
    DWORD       PID=0;
    DWORD       TID;

    if (!pbWindowChanged)
        return FALSE;
    *pbWindowChanged=FALSE;

    if (!this->bCapture)
        return TRUE;

    if(!this->bInitializeDone)
        return FALSE;

    // get window handle from point
    if (this->bSelectOnlyDialog)
    {
        hWnd = WindowFromPoint (pt);
        hWndTmp=NULL;
        while(hWnd)
        {
            hWndTmp=hWnd;
            hWnd=GetParent(hWndTmp);
        }
        // get last not null handle
        hWnd=hWndTmp;
    }
    else
        hWnd = this->SmallestWindowFromPoint (pt);

    if (!hWnd)
        return FALSE;

    // get window thread and pid from handle
    TID = GetWindowThreadProcessId (hWnd, &PID);

    // check if we can select our window
    if (!this->bOwnerWindowSelectable)
    {
        // if selected window is our one
        if (GetCurrentProcessId () == PID)
            return TRUE;
    }
    
    // if mouse has not changed of window
    if (this->hWndOld == hWnd)
        return TRUE;    // prevent flickering

    *pbWindowChanged=TRUE;

    // if an old window was highlight remove highlight
    if(this->hWndOld) 
        HighlightWindow(this->hWndOld,FALSE);
    else
    {
        if (this->bMinimizeOwnerWindowWhenSelect)
        {
            // assume the first selected window is refreshed before highlighting it
            // else highlightement will be lost (done before the refresh)
            // and as we currently do a xor on window border regardless to flag passed
            // the window will be highlighted when you leave it... quite surprising for the user
            UpdateWindow(hWnd);
        }
    }

    // highlight new selected window
    HighlightWindow(hWnd,TRUE);
    // update old window handler
    this->hWndOld = hWnd;

    return this->GetHandleInfo(hWnd);
}
Esempio n. 5
0
//-----------------------------------------------
// MainDlgProc
// Notice: dialog procedure
//
BOOL CALLBACK MainDlgProc (HWND hDlg,	// handle to dialog box
						   UINT uMsg,      // message
						   WPARAM wParam,  // first message parameter
						   LPARAM lParam ) // second message parameter
{
	POINT pt;
	RECT rc;
	static bCapture = false;

	static HBITMAP		hBmpCross;
	static HBITMAP		hBmpBlank;
	

	switch (uMsg) {

	case WM_INITDIALOG:
		hStatic		= ::GetDlgItem(hDlg,IDC_CAPTURE);
		hBmpCross	= LoadBitmap (hInst, MAKEINTRESOURCE(IDB_CROSS));
		hBmpBlank	= LoadBitmap (hInst, MAKEINTRESOURCE(IDB_BLANK));
		hCurCross	= LoadCursor (hInst, MAKEINTRESOURCE(IDC_CROSS0));
		hCurHot		= LoadCursor (hInst, MAKEINTRESOURCE(IDC_CROSS1));
		hCurNormal  = LoadCursor (NULL, IDC_ARROW);
		return true;
		
	case WM_LBUTTONDOWN:
		pt.x = MAKEPOINTS(lParam).x;
		pt.y = MAKEPOINTS(lParam).y;		
		::ClientToScreen (hDlg, &pt);
		
		::GetWindowRect(hStatic, &rc);

		if( ::PtInRect(&rc, pt) )
		{
			::SetCursor( hCurCross );
			::SendMessage (hStatic,STM_SETIMAGE,IMAGE_BITMAP,(long)hBmpBlank);
			::SetCapture( hDlg );
			bCapture = true;
		}
		break;
	
	case WM_LBUTTONUP:
	case WM_KILLFOCUS:
		if( bCapture )
		{
			if( hWndOld )
				HighlightWindow(hWndOld,FALSE);
			hWndOld = NULL;

			::SetCursor( hCurNormal );
			::SendMessage (hStatic,STM_SETIMAGE,IMAGE_BITMAP,(long)hBmpCross);
			::ReleaseCapture();
			bCapture = false;
		}
		break;

	case WM_MOUSEMOVE:
		if (bCapture) {
			pt.x = MAKEPOINTS(lParam).x;
			pt.y = MAKEPOINTS(lParam).y;			
			::ClientToScreen (hDlg, &pt);
			OnMouseMove (hDlg, pt);
		}
		break;

	case WM_CTLCOLOREDIT:
		if (bOverPasswdEdit)
		{
			HDC hdc = (HDC) wParam;
			if (GetDlgItem (hDlg,IDC_EDIT3) == (HWND) lParam)
			{
				SetBkColor (hdc, RGB(255,255,160));
				return (BOOL) brush;
			}
		}
		break;

	case WM_CLOSE:
		::KillTimer (hDlg,100);
		::EndDialog (hDlg, 0);
		return true;		
	}

	return false;
}
Esempio n. 6
0
//-----------------------------------------------
// OnMouseMove
// Notice: updates edit controls
//
void OnMouseMove (HWND hDlg, POINT &pt)
{
//	HWND hWnd = ::WindowFromPoint (pt);
	HWND hWnd = SmallestWindowFromPoint (pt);

	DWORD PID, TID;
	TID = ::GetWindowThreadProcessId (hWnd, &PID);

	if (GetCurrentProcessId () == PID)
		return;	
	 
	if (hWndOld == hWnd) return;	// prevent flickering
	if(hWndOld) 
		HighlightWindow(hWndOld,FALSE);
	HighlightWindow(hWnd,TRUE);
	hWndOld = hWnd;

	_TCHAR ch[128];         // text buffer

	/////////////////////////////////////////////////////////////
	//
	// Insert data into edit ctrls
	//
	// 1. parent window
	//
	HWND hParent = ::GetParent (hWnd);
	if (hParent != NULL) 
	{
		_stprintf (ch, __TEXT("0x%08X"), hParent);
		::SetDlgItemText (hDlg, IDC_EDIT9, ch);		// parent handle

		::GetWindowText (hParent, ch, 128);
		::SetDlgItemText (hDlg, IDC_EDIT10, ch);    // parent text

		::GetClassName (hParent, ch, 128);
		::SetDlgItemText (hDlg, IDC_EDIT11, ch);    // parent class name
	}
	else
	{
		::SetDlgItemText (hDlg, IDC_EDIT9,  __TEXT("N/A"));
		::SetDlgItemText (hDlg, IDC_EDIT10, __TEXT("N/A"));
		::SetDlgItemText (hDlg, IDC_EDIT11, __TEXT("N/A"));
	}
	//	

	//**//
	//
	// 2. window under cursor
	//
	_stprintf (ch, __TEXT("0x%08X"), hWnd);
	::SetDlgItemText (hDlg, IDC_EDIT1, ch);      // window handle

	int nID = GetWindowLong(hWnd, GWL_ID);
	_stprintf (ch, __TEXT("%d"), nID);
	::SetDlgItemText (hDlg, IDC_EDIT2, ch);      // control ID
	
	DWORD style = (DWORD)::GetWindowLong (hWnd, GWL_STYLE);
	_stprintf (ch, __TEXT("0x%08X"), style);	
	::SetDlgItemText (hDlg, IDC_EDIT5, ch);      // window style

	RECT rc; 
	::GetWindowRect(hWnd, &rc);
	_stprintf (ch, __TEXT("(%d, %d)-(%d, %d) %dx%d"), rc.left, rc.top, rc.right, rc.bottom,
													  rc.right - rc.left, rc.bottom - rc.top);
	::SetDlgItemText (hDlg, IDC_EDIT6, ch);      // RECT

	_stprintf (ch, __TEXT("0x%08X"), TID);
	::SetDlgItemText (hDlg, IDC_EDIT7, ch);      // thread ID

	_stprintf (ch, __TEXT("0x%08X"), PID);
	::SetDlgItemText (hDlg, IDC_EDIT8, ch);      // process ID


	::GetClassName (hWnd, ch, 128);
	::SetDlgItemText (hDlg, IDC_EDIT4, ch);      // class name
	
	if (GetCurrentProcessId () != PID)
	{
		if ((!_tcsicmp(ch,__TEXT("EDIT"))	|| 
			!_tcsicmp(ch, __TEXT("TEDIT"))	|| 
			!_tcsicmp(ch, __TEXT("ThunderTextBox")) ||
			!_tcsicmp(ch, __TEXT("ThunderRT6TextBox")) ||
			!_tcsicmp(ch, __TEXT("Iris.Password"))) &&			
			style & ES_PASSWORD)
		{	// cursor over Edit Control with ES_PASSWORD
			bOverPasswdEdit = true;
			::SetCursor( hCurHot );
			
			HANDLE hProcess = 
			OpenProcess(
				PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ,
				FALSE, PID);		

			if (hProcess != NULL) {
				MessageBeep(MB_OK);
				GetWindowTextRemote (hProcess,hWnd,ch);
				CloseHandle( hProcess );
			}
			else 
				_tcscpy (ch,__TEXT(""));
		}
		else {
			::SendMessage (hWnd, WM_GETTEXT, 128, (LPARAM)ch);
			bOverPasswdEdit = false;
			::SetCursor( hCurCross );
		}
	}
	::SetDlgItemText (hDlg, IDC_EDIT3,ch );         // window text
}