突出显示MFC中的静态 [英] Highlight over the static in MFC

查看:98
本文介绍了突出显示MFC中的静态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a rectangle on dialog box where I have some text. It is CBCGPStatic.
I have a method OnMouseMove(UINT nFlags, CPoint point) which I want to use to highlight the area of this static.

Is any way to do it?





我尝试了什么:





What I have tried:

<pre lang="c++">

void CStartPage::OnMouseMove(UINT nFlags, CPoint point)
{   .....
 if()
{
<pre><pre>pDC->FillSolidRect(rect, clrTabSelected);



}




}

I create my own class where I derrived CBCGPStatic and write method code BOOL StaticStartpage::OnEraseBkgnd(CDC * pDC) { ASSERT_VALID(pDC); CRect rectClient; GetClientRect(rectClient); //pDC->FillRect(rectClient, clrTabSelected); CBrush brush(clrTabSelected); CBrush *pbrush = pDC->SelectObject(&brush); if (m_bHighlighted) { //pDC->FillSolidRect(rectClient, clrTabSelected); pDC->FillRect(rectClient, &brush); } return TRUE; } code , but it didn't help..





// UpdateWindow();

CBCGPDialog: :OnMouseMove(nFlags,point);

}



//UpdateWindow();
CBCGPDialog::OnMouseMove(nFlags, point);
}

推荐答案

到目前为止,我还没有将BCGSuite用于MFC。所以这可能没有帮助。



但你想要实现的是悬停并且通常由控件处理,而不是由对话框处理。所以你必须从 CBCGPStatic 派生一个类并在那里实现它。



调用TrackMouseEvent功能(Windows) [ ^ ]获取通知消息并处理它们。为了突出显示,它应该足以根据悬停状态更改文本和可选的背景颜色,并使其无效以强制重绘。



有一个(相当旧) CodeProject上的文章解释了它:向任何控件添加鼠标功能 [ ^ ]这解释了如何做到这一点。
I have not used the BCGSuite for MFC so far. So this might not help.

But what you want to achieve is called hovering and is usually handled by the control and not by the dialog. So you have to derive a class from CBCGPStatic and implement it there.

Call the TrackMouseEvent function (Windows)[^] to get notification messages and handle them. For highlighting it should be sufficient to change the text and optionally the background colour according to the hover state and invalidate to force a redraw.

There is a (rather old) article here at CodeProject that explains it: Adding mouse functionality to any control[^] that explains how to do it.


这篇关于突出显示MFC中的静态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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