page setup problem

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

page setup problem

Post by Cosmin3 »

I think there is a problem with the new version 2.2.2.
I create a window with srv. Right after this (in the same procedure) I set a lot of things in which this one:

srvEditor.UnitsProgram := rvuMillimeters;
SclRVRuler1.UnitsDisplay := ruMillimeters;
SclRVRuler2.UnitsDisplay := ruMillimeters;
srvEditor.SetMarginUnit(25, 15, 10, 15);

The problem is that srveditor.PageProperty.BottomMargin is 0.3 after the window is shown.
If I try ShowMessage(FloatToStr(srveditor.PageProperty.BottomMargin)) right after this code says that is 15.081 (!).
After the window is shown (but not in that procedure) if I try this code works fine.
So the problem is that I use it right after creation.

This code worked 100% for versions <= 2.2.1.

Is there something that can be done...?
Thank you.
Last edited by Cosmin3 on Sat Aug 22, 2009 1:30 pm, edited 1 time in total.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

We tried to reproduce this bug in the following code:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
rvEditor := TSRichViewEdit.Create(nil);
rvEditor.Parent := self;
SclRVRuler1.SRichViewEdit := rvEditor;
SclRVRuler2.SRichViewEdit := rvEditor;

rvEditor.UnitsProgram := rvuMillimeters;
SclRVRuler1.UnitsDisplay := ruMillimeters;
SclRVRuler2.UnitsDisplay := ruMillimeters;
rvEditor.SetMarginUnit(25, 15, 10, 15);
ShowMessage(FloatToStr(rvEditor.PageProperty.BottomMargin));

// rvEditor.Parent := nil;
// rvEditor.Destroy;
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
ShowMessage(FloatToStr(rvEditor.PageProperty.BottomMargin));
end;
Both messages (just after the creation, and when clicking on the second button) display 15.
Probably some other code resets margins. Can you send a project reproducing this problem to Ilya?
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

Post by Cosmin3 »

My code is:

Code: Select all

   if Busy then
      Exit;
   with TfrmMainChild.Create(Self) do
   begin
      Busy := True;
      WindowState := wsMaximized;
      Constraints.MinWidth := 640;
      Constraints.MinHeight := 480;
      srvEditor.RichViewEdit.Style.SelectionMode := rvsmChar;
      srvEditor.RichViewEdit.Clear;
      with srvEditor.RichViewEdit.Style do
         for i := 0 to TextStyles.Count - 1 do
            TextStyles[i].Unicode := True;
      idChildUnic := Abs(Handle);
      RVALocalizeRuler(SclRVRuler1);
      RVAControlPanel1.DefaultControl := srvEditor.RichViewEdit;
      TSRVToolButton(srvtlwndw1.Buttons.Items[0]).Caption := TextRo('Arie editabilã');
      TSRVToolButton(srvtlwndw1.Buttons.Items[1]).Caption := TextRo('Cãutare');
      TSRVToolButton(srvtlwndw1.Buttons.Items[2]).Caption := TextRo('Înlocuire multiplã');
      TSRVToolButton(srvtlwndw1.Buttons.Items[3]).Caption := 'DEX';
      TSRVToolButton(srveditor.MenuHButtons.Items[0]).Hint := TextRo('Suport punctuaþie');
      TSRVToolButton(srveditor.MenuHButtons.Items[4]).Hint := TextRo('Riglã');
      PageModes := pmBreakPage;
      FileType := ftRTF;
      lbInfo.Caption := 'Nr. sugestii: 0       ';
      btnCloseSuport.Hint := TextRo('Închide');
      lbCaption.Caption := TextRo('Suport punctuaþie');
      Caption := 'Fara titlu.rtf';
      FullFileName := '';
      TextLoaded := False;
      frmMain.cmbListZoom.ItemIndex := 3; //3 = default pe 100 %
      if Pos('%', cmbListZoom.Text) > 0 then
         srvEditor.ViewProperty.ZoomPercent := StrToIntDef(Copy(cmbListZoom.Text, 1, Length(cmbListZoom.Text) - 1), 0)
      else
         srvEditor.ViewProperty.ZoomPercent := StrToIntDef(cmbListZoom.Text, 0);
      RememberZoomMode := srvEditor.ViewProperty.ZoomMode;
      RememberZoomPercent := srvEditor.ViewProperty.ZoomPercent;
      RememberPageFormat := srvEditor.PageProperty.PageFormat;
      srvEditor.UnitsProgram := rvuMillimeters;
      SclRVRuler1.UnitsDisplay := ruMillimeters; //ruCentimeters;
      SclRVRuler2.UnitsDisplay := ruMillimeters; //ruCentimeters;
      srvEditor.SetMarginUnit(25, 15, 10, 15);
//      ShowMessage(FloatToStr(srveditor.PageProperty.BottomMargin));
      SclRVRuler1.Scrolled;
      SclRVRuler2.Scrolled;
      SclRVRuler1.DoMarginChanged;
      srvEditor.PageProperty.PageNoVisible := False;
      if frmConfig.cbHideRigla.Checked then begin
         Panel3.Visible := False;
         SclRVRuler1.Visible := False;
         SclRVRuler2.Visible := False;
      end;
      FontName := frmConfig.pnlFontExDoc.Font.Name;
      FontSize := frmConfig.pnlFontExDoc.Font.Size;
      Busy := False;
      with rvActionFontEx1 do
      begin
         UserInterface := False;
         ValidProperties := [rvfimFontName, rvfimSize, rvfimCharset, rvfimBold, rvfimItalic, rvfimUnderline, rvfimStrikeout, rvfimOverline, rvfimColor];
         Font := frmConfig.pnlFontExDoc.Font;
         Execute;
         UserInterface := True;
      end;
      if cmbFontName.Items.Count > 0 then
      begin
         cmbFontName.ItemIndex := cmbFontName.Items.IndexOf(frmConfig.pnlFontExDoc.Font.Name); // 'Times New Roman'
         cmbFontSize.FontName := frmConfig.pnlFontExDoc.Font.Name; //'Times New Roman';
         cmbFontSize.ItemIndex := cmbFontSize.Items.IndexOf(IntToStr(frmConfig.pnlFontExDoc.Font.Size)); //'11');
      end;
      srvEditorCurrentPageChange(Self);
      srvEditor.OnCaretMove := srvEditorCaretMove;
      srvEditor.OnCaretMove(Self);
      Busy := True;
      pnlContainerMesaj.Constraints.MaxHeight := Height div 2 - 20;
      SetRiglaUnits(False);
      AddItemMenu(idChildUnic, Caption);
      srvEditor.RichViewEdit.Delimiters := ' .;,:(){}"/\<>!?[]+*='#$91#$92#$93#$94#$A0#$84;
      Show;
      if frmMain.Showing then
         srvEditor.SetFocus;
      srvEditor.RichViewEdit.Modified := False;
      srvEditor.RichViewEdit.ClearUndo;
      Busy := False;
   end;
Some of the code is specific to my program but hopefully that it will give you an idea about how it works.
I tried this first because it's not very easy to make a smaller program to reproduce the problem..
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

We found a bug in the ruler.
A quick fix:
unit: SclRVRuler.pas
procedure TSclRVRuler.DoMarginChanged;
line 567, change from

Code: Select all

if (RulerType = rtVertical) then
  FSRichViewEdit.SetMargin(-1, FSRichViewEdit.TopMargin100Pix,
    -1, FSRichViewEdit.BottomMargin100Pix)
else
  FSRichViewEdit.SetMargin(FSRichViewEdit.LeftMargin100Pix, -1,
    FSRichViewEdit.RightMargin100Pix, 1);
to

Code: Select all

if (RulerType = rtVertical) then
  FSRichViewEdit.SetMargin(-1, FSRichViewEdit.TopMargin100Pix,
    -1, FSRichViewEdit.BottomMargin100Pix)
else
  FSRichViewEdit.SetMargin(FSRichViewEdit.LeftMargin100Pix, -1,
    FSRichViewEdit.RightMargin100Pix, [color=red]-1[/color]);
Besides, change in your code:

Code: Select all

SclRVRuler1.Scrolled;
SclRVRuler2.Scrolled;
SclRVRuler1.DoMarginChanged;
to

Code: Select all

SclRVRuler1.CheckMargin;
SclRVRuler2.CheckMargin;
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

Post by Cosmin3 »

Yes, it works fine now :)
Thank you very much for the quick fix.
Best regards.
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

Post by Cosmin3 »

A smaller problem: is it normal that at every use of srv.ScrollToCaret to show the ScrollHint..?
How can I deactivate it (without deactivating it at the use of Scrollbar)..?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

A quick fix:
Unit: SclRView.pas
function TSRichViewEdit.ScrollToCaret: Boolean;
line: 10793

Change from

Code: Select all

HScrollPos := LeftItem - 1;
VScrollPos := (TopItem div FRichViewEdit.VSmallStep) - 1;
to

Code: Select all

fBusyScroll := True;
HScrollPos := LeftItem - 1;
VScrollPos := (TopItem div FRichViewEdit.VSmallStep) - 1;
fBusyScroll := False;
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

Post by Cosmin3 »

Thank you for this fix too..
Cosmin3
Posts: 54
Joined: Sat Apr 05, 2008 12:04 pm

Post by Cosmin3 »

Hi.
I just found another problem: let's say I opened a document. I go with text cursor to the last visible text line in page and start pressing Down key. Every time I press the key the scroll hint appears.
Same thing happens when I go up.
It's annoying to see that scroll hint every time for those users who check dozens of text pages every day.
Less annoying but still.. is when you scroll the text with mouse wheel.
In both cases the scroll hint should be showed only (at most) when you enter in another page.

How can I solve these...?
Thank you in advance.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Confirmed. Will be fixed in the next update.
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post by proxy3d »

It is fixed in version SRV 2.5
Post Reply