本文介绍了CMFCButtons - 有没有人真正使用这些?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试使用CMFCButton,因为当鼠标悬停在工具提示和热位图时,它们内置了对工具提示和热位图的支持,但它们似乎没有任何工具可以显示按下(即选定的)位图 - 也就是说,你需要将它们视为所有者绘制并添加:

 ON_WM_DRAWITEM()
...
void CMyClass :: OnDrawItem( int nIDCtl,LPDRAWITEMSTRUCT lpDrawItemStruct)
{
etc ...





除非上面启用OnDrawItem(),否则鼠标悬停时不再显示热位图,以下内容如下与CButton一起使用的OnDrawItem()中的代码不再适用于CMFCButton:



  //  永远不会设置ODS_SELECTED  
int s =(lpDrawItemStruct-> ; itemState& ODS_SELECTED);





总而言之,对于所有者抽奖,我无法以传统方式捕获左键(ODS_SELECTED是设置)为了绘制按下的位图,我也不能得到鼠标悬停的热位图。



任何人都有任何想法?截至目前,CMFCButton似乎是从CButton向后退一步。

解决方案



I have tried to use CMFCButton's because they have built-in support for tooltips and hot bitmaps when you mouse over them, but they don't seem to have any facility to display the "pressed" (i.e. selected) bitmap - which is to say, you need to treat them as owner-draw and add:

ON_WM_DRAWITEM()
    ...
    void CMyClass::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
    {
        etc...



Except that when you enable OnDrawItem() as above, the hot bitmap no longer displays on mouse over, and the following code in OnDrawItem(), which works with CButton, no longer works with CMFCButton:

    // ODS_SELECTED is never set
int s = (lpDrawItemStruct->itemState & ODS_SELECTED);



So in summary, with owner-draw, I cannot capture a left button down in the traditional way (ODS_SELECTED is set) in order to draw the "pressed" bitmap, nor can I get mouse-over hot bitmap.

Anyone got any ideas? As of right now, CMFCButton seems like a step backwards from CButton.

解决方案



这篇关于CMFCButtons - 有没有人真正使用这些?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 00:32