|
RecalcScrollBars is causing the scrollbar to show and hide at the same call, which in turn is causing the control to be repainted and the scrollbar to flicker. This can be avoided by doing the following:
Replace RecalcScrollBars with the code below
void CXTPSyntaxEditCtrl::RecalcScrollBars()
{
if (!XTPSyntaxEditPaintManager()->GetFont()->GetSafeHandle())
return;
// create scroll bar info
SCROLLINFO info;
ZeroMemory(&info, sizeof(SCROLLINFO));
int nTopRow = m_nTopCalculatedRow = GetDocumentRow(1);
int nBottomRow = m_nBottomCalculatedRow = GetDocumentRow(GetRowPerPage());
int iMax = m_pBuffer->CalcMaxLineTextLength(nTopRow, nBottomRow);
int nVisRows = GetVisibleRowsCount();
int iPageX = 20, iPageY = 20;
if (::IsWindow(m_hWnd))
{
CXTPClientRect rcWnd(this);
iPageX = rcWnd.Width() / m_tm.tmAveCharWidth;
iPageY = rcWnd.Height() / m_tm.tmHeight;
iMax += iPageX/2;
}
if (GetRowCount() <= 0)
{
GetScrollInfo(SB_VERT, &info);
info.cbSize = sizeof(info);
info.fMask = SIF_DISABLENOSCROLL | SIF_PAGE;
info.nPage = iPageY;
SetScrollInfo(SB_VERT, &info);
EnableScrollBarCtrl(SB_VERT);
GetScrollInfo(SB_HORZ, &info);
info.nMax = iMax;
info.nPage = iPageX;
info.fMask = SIF_DISABLENOSCROLL | SIF_PAGE;
SetScrollInfo(SB_HORZ, &info);
}
else
{
GetScrollInfo(SB_HORZ, &info);
int nMaxRowInPage = GetRowPerPage();
info.nMax = iMax;
info.nPage = iPageX;
info.fMask = SIF_DISABLENOSCROLL | SIF_PAGE | SIF_POS | SIF_RANGE;
SetScrollInfo(SB_HORZ, &info);
EnableScrollBarCtrl( SB_HORZ );
GetScrollInfo(SB_VERT, &info);
info.nPage = iPageY;
BOOL bVertScrl = (nVisRows >= nMaxRowInPage);
if (bVertScrl)
{
info.nMin = 1;
info.nMax = nVisRows;
info.fMask = SIF_DISABLENOSCROLL | SIF_PAGE | SIF_POS | SIF_RANGE;
SetScrollInfo(SB_VERT, &info);
}
EnableScrollBarCtrl(SB_VERT, bVertScrl);
}
CalculateEditbarLength(); }
|