Print Page | Close Window

CXTPSyntaxEditCtrl ScrollBar problem

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=6010
Printed Date: 12 November 2025 at 3:25am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPSyntaxEditCtrl ScrollBar problem
Posted By: Italo
Subject: CXTPSyntaxEditCtrl ScrollBar problem
Date Posted: 05 January 2007 at 2:36pm

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();

}



Replies:
Posted By: sserge
Date Posted: 08 January 2007 at 7:24am
Thanks, we'll update it.

--
WBR,
Serge



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net