如何在MFC中移动鼠标时给按钮着色 [英] How to color the button on mouse move in mfc

查看:731
本文介绍了如何在MFC中移动鼠标时给按钮着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,我想在鼠标移动按钮时更改mfc中按钮的外观.

Actually i want to change the appearence of the button in mfc when the mouse move on the button.

推荐答案

您必须编写自己的类来更改颜色MFC中的按钮.请查看此链接,例如:
http://people.msoe.edu/~taylor/examples/colorButton.htm [ ^ ]

然后尝试处理WM_MOUSEMOVEWM_MOUSELEAVE消息,以了解鼠标何时进入/释放按钮.

---------------------------------------

查看此链接以了解如何渲染所有者绘制按钮:
http://www.codeguru.com/cpp/controls/buttonctrl/article.php/c5157 [^ ]

查看此行以了解按钮何时聚焦:
You must write your own class to change the color of button in MFC. Check out this link for example:
http://people.msoe.edu/~taylor/examples/colorButton.htm[^]

Then try to handle the WM_MOUSEMOVE and WM_MOUSELEAVE messages to know when the mouse enters/leaves the button.

---------------------------------------

Check out this link to know how to render a owner draw button:
http://www.codeguru.com/cpp/controls/buttonctrl/article.php/c5157[^]

Look at this line to know when the button is focused:
if ( (state & ODS_FOCUS ) )       // If the button is focused
{
    //change the color here...
}


这篇关于如何在MFC中移动鼠标时给按钮着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆