微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 测试测量 > 虚拟仪器 > 请问在CVI环境下怎么实现在鼠标移动到某个控件上时改变形状?

请问在CVI环境下怎么实现在鼠标移动到某个控件上时改变形状?

时间:12-13 整理:3721RD 点击:
我现在用的是CVI7.0。想实现当鼠标移动到(不点击)一个command button上时,鼠标的形状改变(比如说编程手的形状)的功能,请问该怎么实现啊? 请大虾们指导。

设置一个timer
//determine whether the mouse is on control
int IsClickCtrl (int panel, int control, int x, int y)
{
    int height, width;
    if ((x < 0) || (y < 0))
        return 0;
    if (control == 0)
    {
        GetPanelAttribute (panel, ATTR_HEIGHT, &height);
        GetPanelAttribute (panel, ATTR_WIDTH, &width);
    }
    else
    {
        GetCtrlAttribute (panel, control, ATTR_HEIGHT, &height);
        GetCtrlAttribute (panel, control, ATTR_WIDTH, &width);
    }
    if ((y < height) && (x < width))
        return 1;
    else
        return 0;
}
在timer函数里面:
/* Change mouse cursor if we are over panel or MESSAGELIST, */
            /* and this panel is the active panel.                      */
            if (GetActivePanel() == panel)
            {
                if (IsClickCtrl (panel, 0, panelX, panelY))
                {
                    if (IsClickCtrl (panel, PANEL_MESSAGEBOX, ctrlX, ctrlY))
                        SetMouseCursor (VAL_OPEN_HAND_CURSOR);
                    else            
                                                SetMouseCursor (VAL_CROSS_HAIR_CURSOR );
                        
                }
                else
                    SetMouseCursor (VAL_DEFAULT_CURSOR);
            }
            else
                SetMouseCursor (VAL_DEFAULT_CURSOR);  

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top