Click here to Skip to main content
15,910,862 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C++
<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);
}
Posted
Updated 17-Jan-18 23:52pm
v3

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900