在spy++中有一个工具叫finder tool,用户可以拖动一个图标,将其放到想要定位的窗口上,这样spy++就可以获得该窗口的句柄。
问:这个图标(或位图,。。)所属哪个类?是如何实现的?
如何响应mousemove、hittest等等已知。

解决方案 »

  1.   

    响应一个Button的拖放
    void CDButton::OnMouseMove(UINT nFlags, CPoint point) 
    {
    if(GetKeyState(VK_LBUTTON) < 0)
    {
                  flag = 1;
                  AfxmessageBox("拖动中...");
    }
    CButton::OnMouseMove(nFlags, point);
    }
    void CDButton::OnLButtonUp( UINT nFlags, CPoint point )
    {
    flag = 0;
             AfxMessageBox("释放中..."); CButton::OnLButtonUp( nFlags, point );
    }
      

  2.   

    vars:
    BOOL m_bDraging;
    m_strSelectedWnd;//和对话框中某编辑框关联的Cstring
    IDC_CURSOR_CAPTURE://光标资源OnLbuttonDown:
    if (!m_bDraging)
    {
    m_bDraging = TRUE;
    SetCapture();
    }OnLbuttonUp:
    if (m_bDraging)
    {
    m_bDraging = FALSE;
    ReleaseCapture();
    }OnMouseMove:
    if (m_bDraging)
    {
    ::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_CAPTURE));
    ClientToScreen(&point);
    HWND hSelectWnd = ::WindowFromPoint(point);
    CString strTitle;
    CWnd::FromHandle(hSelectWnd)->GetWindowText(strTitle);
    m_strSelectedWnd.Format("HWND:%p \"%s\"", (void *)hSelectWnd, strTitle);
    UpdateData(FALSE);
    }
      

  3.   

    谢谢两位解答。我昨晚已经得出答案了,跟timepalette朋友的差不多。因为在spy++中也就是用的CurSor做的。timepalette好象也在做这个?连m_strSelectedWnd这个想法也跟我一致,不过代码风格比我要好。
    这个贴子nonocast得5分,timepalette得15分。