如何实现让鼠标移动到一CStatic上的时候,点击实现超链接!

解决方案 »

  1.   

    用ShellExcute吧.
    看看:http://topic.csdn.net/u/20071221/15/e2fe650b-bc00-452a-8628-0578311e6493.html
      

  2.   


    void CTestDlg::OnMouseMove(UINT nFlags, CPoint point)
    {
    // TODO: 在此添加消息处理程序代码和/或调用默认值
    CRect rcLink;
    m_Link.GetClientRect( &rcLink );
    m_Link.ClientToScreen( &rcLink );
    ScreenToClient( &rcLink ); if( point.x > rcLink.left && point.x < rcLink.right && point.y > rcLink.top && point.y < rcLink.bottom )
    {
    HCURSOR hCursor;
    hCursor = ::AfxGetApp()->LoadCursorW( IDC_HAND ); SetCursor( hCursor );
    }
    CDialog::OnMouseMove(nFlags, point);
    }void CTestDlg::OnLButtonDown(UINT nFlags, CPoint point)
    {
    // TODO: 在此添加消息处理程序代码和/或调用默认值
    CRect rcLink;
    m_Link.GetClientRect( &rcLink );
    m_Link.ClientToScreen( &rcLink );
    ScreenToClient( &rcLink ); if( point.x > rcLink.left && point.x < rcLink.right && point.y > rcLink.top && point.y < rcLink.bottom )
    {
    if( nFlags == MK_LBUTTON )
    ShellExecute( NULL, NULL, _T("http://www.csdn.net"), NULL, NULL, SW_NORMAL );
    }
    CDialog::OnLButtonDown(nFlags, point);
    }
      

  3.   

    我应该怎么样来判断鼠标移动到了我CStatic的位置上了呢!
      

  4.   


    CRect   rcLink; 
    m_Static.GetClientRect(   &rcLink   ); // 这个m_Static就是你
    m_Static.ClientToScreen(   &rcLink   ); 
    ScreenToClient(   &rcLink   ); if(   point.x   >   rcLink.left   &&   point.x   <   rcLink.right   &&   point.y   >   rcLink.top   &&   point.y   <   rcLink.bottom   ) 
    {
        // 移动到了static上了
    }
      

  5.   

    这个LoadCursor我改了
    hCursor = ::LoadCursor(NULL, IDC_HAND );
    那样写可能没效果
      

  6.   

    m_link应该是指静态控件吧
    恩 是CStatic类型的的变量
      

  7.   

    ((CStatic*)GetDlgItem(IDC_STATIC1))->GetClientRect(&rcLink); 就这有点区别塞!
    但是这样的吧!
      

  8.   

    8楼的 我的E-Mail [email protected]
    先谢达!
      

  9.   

    最好就从CStatic继承一个类嘛,不久好用了。
      

  10.   

    OnMouseMove的if语句里下个断点吧,看看鼠标放在区域内的时候,进断点了没,自己调调吧,这么多天了 解决了吧
      

  11.   

    m_Link 是怎么定义的啊?  怎么确定你那个m_Link就是他的 CStatic  啊?大哥,,我不明白啊