Page 1 of 1
External scrollbars
Posted: Sat Apr 22, 2006 9:20 pm
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.
Posted: Sat Apr 22, 2006 9:23 pm
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?
Posted: Sat Apr 22, 2006 11:30 pm
by aoven
Well, I'm happy to say that the ScrollParent idea appears to be working smoothly!
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.
Posted: Thu Apr 27, 2006 7:03 pm
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 ?
Posted: Fri Apr 28, 2006 8:54 pm
by aoven
Interesting! I'll need to investigate if everything works the same. Thanks for putting this demo together!
Posted: Tue May 02, 2006 12:48 pm
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.
Posted: Tue May 02, 2006 4:28 pm
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.
Posted: Tue May 02, 2006 4:58 pm
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.
Posted: Tue May 02, 2006 5:10 pm
by Sergey Tkachenko
Sorry, I misprinted, I wanted to write "vertical"