Change color background of astatic text 
Author Message
 Change color background of astatic text

How can I change the background color of a static text
when the mouse is over it, and as soon as mouse-pointer
leave color back to transparent.

thanks in advance for your help,
  Eduardo



Tue, 12 Oct 2004 04:43:33 GMT  
 Change color background of astatic text


Tue, 12 Oct 2004 11:35:27 GMT  
 Change color background of astatic text
Map messages WM_MOUSEMOVE, WM_MOUSELEAVE and WM_CTLCOLOR..

Set a flag in WM_MOUSEMOVE and reset this in WM_MOUSELEAVE. According to
this flag create a brush and return in WM_CTLCOLOR.

Soorej


Quote:
> How can I change the background color of a static text
> when the mouse is over it, and as soon as mouse-pointer
> leave color back to transparent.

> thanks in advance for your help,
>   Eduardo



Tue, 12 Oct 2004 15:41:07 GMT  
 Change color background of astatic text
thanks,

I found this code in Charles Petzold book:

//////////////////////////////////////////////////////////
///////////////////
// CStatic1 message handlers

void CStatic1::OnMouseMove(UINT nFlags, CPoint point)
{
if (!m_bMouseOver)
        {
        this->SetWindowText("1111111");
        m_bMouseOver = TRUE;
        TRACKMOUSEEVENT tme;
        tme.cbSize = sizeof(tme);
        tme.dwFlags = TME_HOVER | TME_LEAVE;
        tme.hwndTrack = CStatic1::GetSafeHwnd();
        tme.dwHoverTime = HOVER_DEFAULT;

        ::TrackMouseEvent(&tme);
        }
//CStatic::OnMouseMove(nFlags, point);

Quote:
}

//******************************************************

LRESULT CStatic1::OnMouseLeave(WPARAM wParam, LPARAM
lParam)
{
        m_bMouseOver = FALSE;
        this->SetWindowText("qqqqqqqq");
        return 0;

Quote:
}

//***************************************************

But ::TrackMouseEvent  give me a compiler error.
Do you know how can I execute TrackMouseEvent inside a
class derived from CStatic ?

Thanks again for your help,
  Eduardo

Quote:
>-----Original Message-----
>Map messages WM_MOUSEMOVE, WM_MOUSELEAVE and
WM_CTLCOLOR..

>Set a flag in WM_MOUSEMOVE and reset this in

WM_MOUSELEAVE. According to
Quote:
>this flag create a brush and return in WM_CTLCOLOR.

>Soorej



>> How can I change the background color of a static text
>> when the mouse is over it, and as soon as mouse-pointer
>> leave color back to transparent.

>> thanks in advance for your help,
>>   Eduardo

>.



Tue, 12 Oct 2004 21:34:56 GMT  
 Change color background of astatic text
Try _TrackMouseEvent

Soorej


Quote:
> thanks,

> I found this code in Charles Petzold book:

> //////////////////////////////////////////////////////////
> ///////////////////
> // CStatic1 message handlers

> void CStatic1::OnMouseMove(UINT nFlags, CPoint point)
> {
> if (!m_bMouseOver)
> {
> this->SetWindowText("1111111");
> m_bMouseOver = TRUE;
> TRACKMOUSEEVENT tme;
> tme.cbSize = sizeof(tme);
> tme.dwFlags = TME_HOVER | TME_LEAVE;
> tme.hwndTrack = CStatic1::GetSafeHwnd();
> tme.dwHoverTime = HOVER_DEFAULT;

> ::TrackMouseEvent(&tme);
> }
> //CStatic::OnMouseMove(nFlags, point);
> }

> //******************************************************

> LRESULT CStatic1::OnMouseLeave(WPARAM wParam, LPARAM
> lParam)
> {
> m_bMouseOver = FALSE;
> this->SetWindowText("qqqqqqqq");
> return 0;
> }
> //***************************************************

> But ::TrackMouseEvent  give me a compiler error.
> Do you know how can I execute TrackMouseEvent inside a
> class derived from CStatic ?

> Thanks again for your help,
>   Eduardo

> >-----Original Message-----
> >Map messages WM_MOUSEMOVE, WM_MOUSELEAVE and
> WM_CTLCOLOR..

> >Set a flag in WM_MOUSEMOVE and reset this in
> WM_MOUSELEAVE. According to
> >this flag create a brush and return in WM_CTLCOLOR.

> >Soorej



> >> How can I change the background color of a static text
> >> when the mouse is over it, and as soon as mouse-pointer
> >> leave color back to transparent.

> >> thanks in advance for your help,
> >>   Eduardo

> >.



Wed, 13 Oct 2004 15:34:01 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Change text color and background color in CEditView

2. Change a part of Background color or a part of text color from CListCtrl

3. changing background color of the text

4. How to change background and text color of CPropertySheet

5. Changing Background Color of CEdit - Problem With Double Clicking On Texts

6. Changing the background color of a static text control

7. Change background color of selected text

8. Developer studio addin - SetWindowsHookEx, changing the text background color

9. Changing Text and Background Color on Pushbuttons

10. Change Background and Text Color of StatusBar

11. Change background and text color in CButton

12. Developer studio addin - SetWindowsHookEx, changing the text background color

 

 
Powered by phpBB® Forum Software