Home > Software engineering >  CScrollView scrollbar automatic hidden and heavy painting scroll bar
CScrollView scrollbar automatic hidden and heavy painting scroll bar

Time:10-02

I want to achieve CScrollView a functions in ChildFrame window: when the mouse enters a ScrollView window) of the region (including all the View of the ScrollBar, a scroll bar, when the mouse left the ScrollView, scroll bars disappear, my CTextView adopted the following code, CTextView inheritance in CSrollView,
 
Void CTextView: onm ouseMove (UINT, CPoint point)
{
CRect rt.
GetClientRect (& amp; Rt);
CSize sizeclient sizebar;
GetTrueClientSize (sizeclient sizebar);
Rt. Right=sizeclient. Cx.//to get real View width, including the horizontal ScrollBar
Rt. Bottom=sizeclient. Cy;//get the real height of the View, including the vertical ScrollBar

TRACKMOUSEEVENT tme.
Tme. CbSize=sizeof (TRACKMOUSEEVENT);
Tme. DwFlags=TME_HOVER | TME_LEAVE;//track the mouse actions
Tme. DwHoverTime=10;
Tme. HwndTrack=m_hWnd;

if (! _TrackMouseEvent (& amp; Tme))
_cprintf (" Track Error! \n");
//determine whether a Point within the scope of the rt and m_ScrollShow is only a sign whether this View shows the ScrollBar labeled a
If (rt) PtInRect (point) & amp; & M_ScrollShow==FALSE) {
CSize temp (400, 500);
SetScrollSizes (MM_TEXT, temp);
M_ScrollShow=TRUE;
return;
}
Else if (! Rt. PtInRect (point)) {
_cprintf (" In CTextView: onm ouseMove Hide Bar!!!!!!!!! \n");
CSize temp (0, 0);
SetScrollSizes (MM_TEXT, temp);//to lose the ScrollBar, put the size to 0
M_ScrollShow=FALSE;
return;
}
return;
}
Void CTextView: : onm ouseLeave () {
CSize temp (0, 0);
SetScrollSizes (MM_TEXT, temp);//if the mouse left CTextView, then let the size of the ScrollBar to 0
M_ScrollShow=FALSE;
return;
}


But, the question now is, when the mouse stay in the region of the ScrollBar, program starts between onm ouseMove and onm ouseLeave continuously circulation, cause the ScrollBar kept flashing, and unable to other behavior (e.g., LButtonDown), in response to the mouse looked at the MFC viewscrl. CPP source, may be the reason is not in the ClientRect MFC default ScrollBar area, cause when the mouse stay in the region of the ScrollBar, the system automatically determine the mouse has left, trigger onm ouseLeave,

My question is: 1, how to implement I described above in a ScrollView derived class function; 2, in the ScrollView drawing ScrollBar in the derived class, what advice, thank you very much!


  • Related