Hello Sergey,
I want to replace a lot TMemo controls in our forms - with TRichViewEdit and a limited set of formating possibilties for our users. The available space on our forms is very limited, so we tried this. I did create a new subclass from TRichViewEdit in the constructor I disabled the original vertical scrollbar and created a new one of your TSRVScrollBar and two additional buttons on top and bottom of it. Now it looks like this at runtime:
The burger button, will show a editing toolbar on top of the control - but not inside the control - so it is nothing you have to worry about,
(the toolbar will be a shared objects for all of our memos and exists only as a single instance)
Looks nice - but doesn't work - I thought it would be enough the override AdjustClientRect() and remove the scrollbar from the "ClientArea" and so
from ClientWidth - but it seems that your painting and calculation isn't useing ClientWidth? or has a copy from it?
So if I type text in single line it will be painted behind the scrollbar.
Also if the richedit starts to scroll verticaly things go wrong - because it tries to scroll also my controls.
(the memo's in that case will use the Option.rvoClientTextWidth = TRUE, to avoid the horizontal scalebar)
Can you offer me some help / hints how to solve this - may I have to override some additional methods to get work?
I have allready found the sample that show's how to use external scrollbars and how to synchronize them with a TRichViewEdit,
that was useful - to keep my scrollbar in sync.
with best regards
André
TRichViewEdit - with own VerticalScrollbar and extra buttons
-
- Site Admin
- Posts: 17553
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: TRichViewEdit - with own VerticalScrollbar and extra buttons
You can simply hide the scrollbars:
VScrollVisible := False;
HScrollVisible := False;
Than place custom scrollbars near the editor.
See https://www.trichview.com/support/files/extscroll.zip
VScrollVisible := False;
HScrollVisible := False;
Than place custom scrollbars near the editor.
See https://www.trichview.com/support/files/extscroll.zip
Re: TRichViewEdit - with own VerticalScrollbar and extra buttons
Hello Sergey,
I would prefer the "subclassing" way - instead of placing extra components around, that would make the life of our GUI designers much eaisier, because they don't need to write any addional code - just add / replace the control.
Do you see a chance that childcontrols of TRichView of a certain kind / class - would be excluded from scrolling / painting?
André
That is what I did inside the constructor of my own class I made the VerticalScrollbar hidden and tried to replace them with my own one.You can simply hide the scrollbars:
VScrollVisible := False;
HScrollVisible := False;
That sample I know allready - this is ok for some or a single usecase but not for a lot.Than place custom scrollbars near the editor.
See https://www.trichview.com/support/files/extscroll.zip
I would prefer the "subclassing" way - instead of placing extra components around, that would make the life of our GUI designers much eaisier, because they don't need to write any addional code - just add / replace the control.
Do you see a chance that childcontrols of TRichView of a certain kind / class - would be excluded from scrolling / painting?
André
-
- Site Admin
- Posts: 17553
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: TRichViewEdit - with own VerticalScrollbar and extra buttons
Children are scrolled in TRVScroller.ScrollChildren.
If it would solve the problem, I can add a virtual method CanBeScrolled(ChildControl: TControl): Boolean and use in this method.
But probably another solution would be simpler: a control that includes both TRIchView and scrollbars as children (this approach is used in DevExpress controls, including TcxTRichViewEdit)
If it would solve the problem, I can add a virtual method CanBeScrolled(ChildControl: TControl): Boolean and use in this method.
But probably another solution would be simpler: a control that includes both TRIchView and scrollbars as children (this approach is used in DevExpress controls, including TcxTRichViewEdit)
Re: TRichViewEdit - with own VerticalScrollbar and extra buttons
Hello,
thanks for your response and pointing me to the right source ... I have modified RvScroll.pas in this way:
I also override TWinControl.GetClientRect - to return only the clientrect without scrollbar so there is no obvious flickering to see.
Only updating the scroll to the correct PageSize/Min/Max seems not the work in all cases - I have to check this.
(Currently I copied your code from the external scrollbar sample, may be I have missed something)
André
thanks for your response and pointing me to the right source ... I have modified RvScroll.pas in this way:
Code: Select all
{------------------------------------------------------}
function TRVScroller.DoAllowScrollChild(const ctrl: TControl): boolean;
begin
// this is a virtual protected method - which I override in my own class, to decide what is scrolled
// my be a good idea to also add dx,dy TRVCoord to this callback, to have all information needed to
// decide about scrolling or not?
result := true;
end;
{------------------------------------------------------}
procedure TRVScroller.ScrollChildren(dx, dy: TRVCoord);
var
i: Integer;
begin
if RVIsZeroCoord(dx) and RVIsZeroCoord(dy) then
exit;
{$IFDEF FIREMONKEY}
for i := 0 to ControlsCount - 1 do
begin
if DoAllowScrollChild(Controls[i]) then
...
end;
{$ELSE}
DisableAlign;
try
for i := 0 to ControlCount - 1 do
begin
if DoAllowScrollChild(Controls[i]) then
begin
....
end;
end
finally
{$IFnDEF FPC}
ControlState := ControlState - [csAlignmentNeeded];
{$ENDIF}
EnableAlign;
end;
{$ENDIF}
end;
Only updating the scroll to the correct PageSize/Min/Max seems not the work in all cases - I have to check this.
(Currently I copied your code from the external scrollbar sample, may be I have missed something)
André
Re: TRichViewEdit - with own VerticalScrollbar and extra buttons
This seemed to work for me, but might need some tweaking on your part:
Code: Select all
FVScrollPage := rve.ClientHeight div rve.VSmallStep;
ScrollBar1.Max := rve.DocumentHeight div rve.VSmallStep;
ScrollBar1.PageSize := FVScrollPage;