Page 1 of 1

How do i properly set a defaultfont within constructor?

Posted: Fri Nov 22, 2013 11:50 am
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.

Posted: Sat Nov 23, 2013 8:51 pm
by Sergey Tkachenko
Sorry, I do not understand what's exactly wrong.
"can not toggle VScrollVisible" - what does it mean?

Posted: Mon Nov 25, 2013 9:19 am
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.

Posted: Mon Nov 25, 2013 4:54 pm
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.

Posted: Fri Nov 29, 2013 11:17 am
by Memnarch
Thank you very much, i'll apply the fix.

Is this going to be in a future update?

Posted: Fri Nov 29, 2013 12:11 pm
by Sergey Tkachenko
yes

Posted: Mon Dec 02, 2013 6:35 pm
by Sergey Tkachenko
Fixed in 14.12.2 (available for registered users)

Posted: Mon Dec 09, 2013 11:40 am
by Memnarch
Thank you very much for this update!