How do i properly set a defaultfont within constructor?

General TRichView support forum. Please post your questions here
Post Reply
Memnarch
Posts: 24
Joined: Mon Jul 08, 2013 7:21 am

How do i properly set a defaultfont within constructor?

Post by Memnarch »

Hi,
I derived from TRichViewEdit, and I'd like to set another defaultsize for the defaultfont and margins.

So what i did is:

Code: Select all

//inside the constructor of my class
inherited
Style := TRVSTyle.Create(Self)
Style.TextSTyles[0].Size := 8;
LeftMargin := X;
RightMargin := X;
BottomMargin := X;
TopMargin := X;
However this has an unwanted sideeffect:

Use any number smaller than 5 for X, you can not toggle VScrollVisible in a Document which has less than 2 lines.

So i must have done something wrong at this point.
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I do not understand what's exactly wrong.
"can not toggle VScrollVisible" - what does it mean?
Memnarch
Posts: 24
Joined: Mon Jul 08, 2013 7:21 am

Post by Memnarch »

if you create a RichView like i described above on a form, add a TButton to it, and in it's eventhandler do this:

Code: Select all

MyEdit.VScrollVisible := not MyEdit.VScrollVisible;
this will do nothing until you add some text to the richviewedit.
Expected behaviour is, that the vertical scrollbar is switched on/off with each click.
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, I can see the problem.
It looks like if a control scrollbar is disabled (because of disable-no-scroll option), it cannot be hidden by simple changing a range where this scrollbar is not needed.

Open RVScroll.pas, find TRVScroller.UpdateScrollBars.
Find

Code: Select all

if VScrollVisible then begin
At the end of the "else" branch of this if, add RV_ShowScrollBar(Handle, SB_VERT, False):

Code: Select all

      else begin
        ScrollInfo.fMask := SIF_ALL;
        RV_GetScrollInfo(Handle, SB_VERT, ScrollInfo);
        with ScrollInfo do
          if (nMin<>0) or (nMax<>1) or (nPage<>0) or (nPos<>0) then begin
            fMask := SIF_ALL;
            nMin := 0;
            nMax := 1;
            nPage := 2;
            nPos := 0;
            RV_SetScrollInfo(Handle, SB_VERT, ScrollInfo, True);
          end;
        [color=red]RV_ShowScrollBar(Handle, SB_VERT, False);[/color]      end;
PS: call Format after assigning VScrollVisible=True to recalculate the scrollbar range.
Memnarch
Posts: 24
Joined: Mon Jul 08, 2013 7:21 am

Post by Memnarch »

Thank you very much, i'll apply the fix.

Is this going to be in a future update?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

yes
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Fixed in 14.12.2 (available for registered users)
Memnarch
Posts: 24
Joined: Mon Jul 08, 2013 7:21 am

Post by Memnarch »

Thank you very much for this update!
Post Reply