CMFCButton的行为不同于CButoon [英] CMFCButton behaves differently than CButoon

查看:521
本文介绍了CMFCButton的行为不同于CButoon的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将CButton更改为CMFCButton,当它们是BS_OWNERDRAW时,行为有所不同:

I changed my CButtons to CMFCButtons and the behavior is different when they are BS_OWNERDRAW:

void CPlayerPane::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	int s = (lpDrawItemStruct->itemState & ODS_SELECTED);



使用CButton,仅使用(s!= 0)调用OnDrawItem()一次,表明用户单击了按钮...,然后可以绘制在"位图.

使用CMFCButtons时,当用户单击按钮(向下键向左)时,OnDrawItem()被称为(s!= 0)*两次,当用户放开鼠标(向左键)时再次被(s!= 0)两次.向上).这正在破坏我的按钮绘制逻辑.

任何人都知道为什么这两种类型的按钮应该具有不同的行为吗?

Thx.



With CButtons, OnDrawItem() gets called only once with (s != 0), indicating that the user has clicked on the button ... and I can draw the "on" bitmap.

With CMFCButtons, OnDrawItem() gets called *twice* with (s != 0)when the user clicks the button (left button down), and twice again with (s != 0) when the user lets off the mouse (left button up). This is playing havoc with my button drawing logic.

Anyone know why these two types of buttons should behave differently?

Thx.

推荐答案

我不知道为什么多次调用该处理程序.但是,您还应该检查lpDrawItemStruct->itemAction成员,以了解需要哪种图纸.可能的值为ODA_SELECTODA_FOCUSODA_DRAWENTIRE.

也许这会向您显示多次调用的原因.
I don''t know why the handler is called multiple times. But you should check also the lpDrawItemStruct->itemAction member to know what kind of drawing is requested. Possible values are ODA_SELECT, ODA_FOCUS, and ODA_DRAWENTIRE.

Maybe this will show you the reason for the multiple calls.


这篇关于CMFCButton的行为不同于CButoon的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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