Greg Smith schrieb:

As I am now attempting to generate a window with a splitter in MFC, I now
appreciate some of the comments that others have made about this. The main
problem seems to be that CSplitterWnd insists on displaying scroll bars in
addition to the ones that Scintilla wants us to use. One can, of course,
turn off the Scintilla scroll bars, but then you have the tedious job of
setting the bars yourself. Has anyone found a satisfactory solution for this
in MFC that they are prepared to share?

Greg Smith
Hi Greg,

there exists a patch for scintilla to support splitter windows with scrollbars in MFC. You can find it on http://www.anyedit.org/scintillapatch.html.

AnyEdit is written in MFC and has splitting support. The source code is available. Here is a code part from the view class:

// ##### Begin Scrollbar specific
LRESULT CAnyEditView::OnGetScrollInfoMsg(WPARAM wParam, LPARAM lParam)
{
   LPSCROLLINFO pInfo = (LPSCROLLINFO)wParam;
   return GetScrollInfo(SCI_SCROLLBAR(lParam), pInfo, pInfo->fMask);
}

LRESULT CAnyEditView::OnSetScrollInfoMsg(WPARAM wParam, LPARAM lParam)
{
   LPSCROLLINFO pInfo = (LPSCROLLINFO)wParam;
   int nBar = SCI_SCROLLBAR(lParam);
   SCROLLINFO info;
   GetScrollInfo(nBar, &info);

   bool bSame = true;
   int nPos = 0;
if ((pInfo->fMask & SIF_RANGE) && ((info.nMax != pInfo->nMax) || (info.nMin != pInfo->nMin)))
       bSame = false;
   if ((pInfo->fMask & SIF_PAGE) && (info.nPage != pInfo->nPage))
       bSame = false;
   if (pInfo->fMask & SIF_POS)
   {
       nPos = pInfo->nPos;
       if (info.nPos != nPos)
           bSame = false;
   }
   else if (pInfo->fMask & SIF_TRACKPOS)
   {
       nPos = pInfo->nTrackPos;
       if (nPos != info.nPos)
           bSame = false;
   }
   if (bSame)
       return TRUE;

   if (!SetScrollInfo(nBar, pInfo, SCI_SCROLL_REDRAW(lParam)))
       return FALSE;

   // Find this pane
   CSplitterWnd* pSplitter = DYNAMIC_DOWNCAST(CSplitterWnd, GetParent());
   if( pSplitter == NULL ) return TRUE;

   int nSize;
   CAnyEditView* pOther;
   if (nBar == SB_VERT)
   {
       // Notify other views in the row that we set the vertical location!
/*        if ((nSize = pSplitter->GetColumnCount()) > 1)
       {
           for (int i=0;i<nSize;i++)
           {
               if (i == nCol)
                   continue;
pOther = DYNAMIC_DOWNCAST(CAnyEditView, pSplitter->GetPane(nRow, i));
               if (pOther != NULL)
                   pOther->m_Scintilla.LineScroll(0, nPos - info.nPos);
           }
       }*/
   }
   else if (nBar == SB_HORZ)
   {
// Notify other views in the column that the horizontal scrollbar moved // and that the view should be updated. This is needed for XP, coz it // doesn't update the other views fast enough after the invalidation of
       // the view.
       if( ( nSize = pSplitter->GetRowCount() ) > 1 )
       {
           for( int i = 0; i < nSize; ++i )
           {
pOther = DYNAMIC_DOWNCAST( CAnyEditView, pSplitter->GetPane( i, 0 ) );
               if( pOther != NULL ) pOther->UpdateWindow();
           }
       }
   }
   return TRUE;
}

void CAnyEditView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
   if (m_Scintilla.GetSafeHwnd() != NULL)
m_Scintilla.SendMessage(WM_HSCROLL, MAKEWPARAM(nSBCode, nPos), (LPARAM)pScrollBar->GetSafeHwnd());
}

void CAnyEditView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
   if (m_Scintilla.GetSafeHwnd() != NULL)
m_Scintilla.SendMessage(WM_VSCROLL, MAKEWPARAM(nSBCode, nPos), (LPARAM)pScrollBar->GetSafeHwnd());
}
// ##### End Scrollbar specific


Regards,

Carsten




_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to