External scrollbars

General TRichView support forum. Please post your questions here
Post Reply
aoven
Posts: 45
Joined: Wed Nov 09, 2005 7:28 pm

External scrollbars

Post by aoven »

I'm trying to implement a Word-like page layout for RVE and I need a way to implement my own scrollbars, because they need to be detached from the actual editor.

I'm having problems synchronizing my custom scrollbars with the actual editor scrolling, because I can't access all the necessary values of the TRVScroller.

Sergey, could you give me some pointers on what would be the best way to do this? If source modifications are required that's ok - I'm perfectly willing to do it manually on my local copy.
aoven
Posts: 45
Joined: Wed Nov 09, 2005 7:28 pm

Post by aoven »

I'm actually toying with the idea to modify TRVScroller implementation by adding a property ala ScrollParent: TWinControl. If this property is assigned TRVScroller would display scrollbars on this control instead on itself.

What do you think?
aoven
Posts: 45
Joined: Wed Nov 09, 2005 7:28 pm

Post by aoven »

Well, I'm happy to say that the ScrollParent idea appears to be working smoothly! :D

If you'd be interested to review the changes and include these modifications into main source, let me know and I'll send you the modified RVScroll.pas.

If not, that's ok, too.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I thought, events and properties are enough, see this demo:
http://www.trichview.com/support/files/extscroll.zip

But may be your idea allows to implement external scrollbars more smoothly ?
aoven
Posts: 45
Joined: Wed Nov 09, 2005 7:28 pm

Post by aoven »

Interesting! I'll need to investigate if everything works the same. Thanks for putting this demo together!
Pieter E.
Posts: 835
Joined: Sun Aug 28, 2005 9:34 am

Post by Pieter E. »

I've tried the source for adding external scrollbars. Replacing the source below works better. The first and last Steps when scrolling are better performed.

Code: Select all

Replace 'HorizScrollBar.Position' for 'ScrollPos':
procedure TScrollForm.HorizScrollBarScroll(Sender: TObject;
  ScrollCode: TScrollCode; var ScrollPos: Integer);
begin
  ScrollRichView.HScrollPos := ScrollPos;
end;

Replace 'VertScrollBar.Position' for 'ScrollPos':
procedure TScrollForm.VertScrollBarScroll(Sender: TObject;
  ScrollCode: TScrollCode; var ScrollPos: Integer);
begin
  ScrollRichView.VScrollPos := ScrollPos;
end;
The source for C++:

Code: Select all

SET TabStop of the Scrollbars to false.

void __fastcall TForm1::ScrollAdjust()
{
  int PageSize;
  vertScrollBar->PageSize = 0;
  if(rve->VScrollMax >0)
        {
          PageSize = rve->ClientHeight / rve->VSmallStep;
          vertScrollBar->Max = rve->VScrollMax + PageSize - 1;
          vertScrollBar->PageSize = PageSize;
        }
  else vertScrollBar->Max = 0;

  vertScrollBar->Position = rve->VScrollPos;
  vertScrollBar->Visible = vertScrollBar->Max > 0;

  horzScrollBar->PageSize = 0;
  if(rve->HScrollMax > 0)
        {
          PageSize = rve->ClientWidth;
          horzScrollBar->Max = rve->HScrollMax + PageSize - 1;
          horzScrollBar->PageSize = PageSize;
        }
  else horzScrollBar->Max = 0;
  horzScrollBar->Position = rve->HScrollPos;
  horzScrollBar->Visible = horzScrollBar->Max > 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::rveResize(TObject *Sender)
{
  ScrollAdjust();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::horzScrollBarScroll(TObject *Sender,
      TScrollCode ScrollCode, int &ScrollPos)
{
  rve->HScrollPos = ScrollPos;//horzScrollBar->Position;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::vertScrollBarScroll(TObject *Sender,
      TScrollCode ScrollCode, int &ScrollPos)
{
  rve->VScrollPos = ScrollPos;//vertScrollBar->Position;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::rveVScrolled(TObject *Sender)
{
  vertScrollBar->Position = rve->VScrollPos;        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::rveHScrolled(TObject *Sender)
{
  horzScrollBar->Position = rve->HScrollPos;
}
//---------------------------------------------------------------------------
Why is the horizontal scrollbar always visible in the TRichViewEdit? Are external scrollbars a solution to remove the 'always visible horizontal scrollbar'?

Good luck,

Pieter E.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Some changes and testing are required to autohide horizontal scrollbar in TRichViewEdit. As for external scrollbars, you can hide them when you need.
Pieter E.
Posts: 835
Joined: Sun Aug 28, 2005 9:34 am

Post by Pieter E. »

Dear Sergey,

I made a mistake in the above post:
Why is the horizontal scrollbar always visible in the TRichViewEdit? Are external scrollbars a solution to remove the 'always visible horizontal scrollbar'?
I meant the vertical scrollbar:
Why is the vertical scrollbar always visible in the TRichViewEdit? Are external scrollbars a solution to remove the 'always visible vertical scrollbar'?

Thanks,

Pieter E.
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I misprinted, I wanted to write "vertical"
Post Reply