Hello Sergey, Hello active customers,
I must be able to move the SclRvRuler1 from point A to point B by code!. The document contains a single Page.
The point B should be at the Bottom of the last item in the SRichViewEdit1 page, in this case a table1.
By the following line :
SclRvRuler1.BottomMargin:=SclRvRuler1.BottomMargin+1;
I could move the bottom of the SclRvRuler1 upword by one point!
Please I need to know how to choose the correct "step" (distance in points between A an B) so I can accomplish that in one step?
SclRvRuler1.BottomMargin:=SclRvRuler1.BottomMargin+Step;
It is a task I requested in previous post without having a satisfying answer.
I believe in your Abilty Sergey, Please would you try to figure out a solution for this issue?! Step:=????????
Thank you in advance!!
Moving SclRvRuler1.BottomMargin by code
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Moving SclRvRuler1.BottomMargin by code
If you want to change the bottom page margin in code, just change it in code. A ruler is not needed for this operation. If TSRichViewEdit has a linked ruler, the ruler will be updated according to the change.
You can simply assign SRichViewEdit.BottomMargin, but this assignment is not an editing operation (not undoable by the user).
Use
NewMarginValue is measured in SRichViewEdit.UnitsProgram.
You can simply assign SRichViewEdit.BottomMargin, but this assignment is not an editing operation (not undoable by the user).
Use
Code: Select all
SRichViewEdit.SetFloatPropertyEd(srvfpPPBottomMargin, NewMarginValue, True);
Re: Moving SclRvRuler1.BottomMargin by code
Thank you for your reply.
It seems I have difficulties to present my problem!
In the Line code you suggested,
SRichViewEdit.SetFloatPropertyEd(srvfpPPBottomMargin, NewMarginValue, True);
I need to calculate NewMarginValue so the BottomMargin(Presented By the Letter 'A' in the ScreenShut I sent) will jump just after the table item in my document. It is vital for me to do that bycode!!
It seems I have difficulties to present my problem!
In the Line code you suggested,
SRichViewEdit.SetFloatPropertyEd(srvfpPPBottomMargin, NewMarginValue, True);
I need to calculate NewMarginValue so the BottomMargin(Presented By the Letter 'A' in the ScreenShut I sent) will jump just after the table item in my document. It is vital for me to do that bycode!!
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Moving SclRvRuler1.BottomMargin by code
In which units Y coordinates of A and B are specified? In screen pixels? Or maybe in the ruler units (I can see centimeters on your screenshot)?
Re: Moving SclRvRuler1.BottomMargin by code
Pixels...
when I execute the Line SclRvRuler1.BottomMargin:=SclRvRuler1.BottomMargin+1; the BottomMargin jump one pixel upword.
I need to know how many pixels there are between points A and B...
I could retrieve the itemRect of the last item(table), then it seems that I should deal with (BottomMargin-ItemRect.Bottom) in the following way
SclRvRuler1.BottomMargin:=SclRvRuler1.BottomMargin+(BottomMargin-ItemRect.Bottom)
The Bottommargin moves close to the bottom of table1 but not exactly!
when I execute the Line SclRvRuler1.BottomMargin:=SclRvRuler1.BottomMargin+1; the BottomMargin jump one pixel upword.
I need to know how many pixels there are between points A and B...
I could retrieve the itemRect of the last item(table), then it seems that I should deal with (BottomMargin-ItemRect.Bottom) in the following way
SclRvRuler1.BottomMargin:=SclRvRuler1.BottomMargin+(BottomMargin-ItemRect.Bottom)
The Bottommargin moves close to the bottom of table1 but not exactly!
Re: Moving SclRvRuler1.BottomMargin by code
Hello Sergey
I Got some help from samples in the demo and could write what I want
it's ok. I found the soluttion...
PageNo:=1;
PageRect:=Rich.GetPageClientRect(PageNo);
Rich.GetPageLastItemNo(PageNo,LastItemNo, Offs);
ItemPart := 0;
ItemRect := Bounds(0, 0, 0, 0);
while Rich.GetItemBounds100(Rich.RichViewEdit.RVData,LastItemNo,
ItemPartRect, FirstPageNo,
PageNo,ItemPart) do
begin
WinApi.Windows.UnionRect(ItemRect, ItemRect, ItemPartRect);
inc(ItemPart);
end;
OffsetRect(ItemRect, PageRect.Left, PageRect.Top);
RVData:=Rich.RichViewEdit.RVData;
Shift:=Rich.PageHeight100Pix-ItemRect.Bottom;
SclRvRuler22.BottomMargin:=Shift;
Thank you
I Got some help from samples in the demo and could write what I want
it's ok. I found the soluttion...
PageNo:=1;
PageRect:=Rich.GetPageClientRect(PageNo);
Rich.GetPageLastItemNo(PageNo,LastItemNo, Offs);
ItemPart := 0;
ItemRect := Bounds(0, 0, 0, 0);
while Rich.GetItemBounds100(Rich.RichViewEdit.RVData,LastItemNo,
ItemPartRect, FirstPageNo,
PageNo,ItemPart) do
begin
WinApi.Windows.UnionRect(ItemRect, ItemRect, ItemPartRect);
inc(ItemPart);
end;
OffsetRect(ItemRect, PageRect.Left, PageRect.Top);
RVData:=Rich.RichViewEdit.RVData;
Shift:=Rich.PageHeight100Pix-ItemRect.Bottom;
SclRvRuler22.BottomMargin:=Shift;
Thank you
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Moving SclRvRuler1.BottomMargin by code
The idea is correct, but there may be problems with DPI.
All *100 properties of TSRichViewEdit (including GetItemBounds100 and PageHeight100Pix) are measured in pixels at 96 DPI.
Ruler.BottomMargin is measured in Ruler.UnitsProgram. As I understand, in your application, Ruler.UnitsProgram = ruPixels. In this case, Ruler.BottomMargin is measured in pixels at DPI specified in Ruler.ScreenRes, which is usually equal to the current screen DPI.
So your code will not work correctly if screen DPI <> 96.
It needs a correction:
All *100 properties of TSRichViewEdit (including GetItemBounds100 and PageHeight100Pix) are measured in pixels at 96 DPI.
Ruler.BottomMargin is measured in Ruler.UnitsProgram. As I understand, in your application, Ruler.UnitsProgram = ruPixels. In this case, Ruler.BottomMargin is measured in pixels at DPI specified in Ruler.ScreenRes, which is usually equal to the current screen DPI.
So your code will not work correctly if screen DPI <> 96.
It needs a correction:
Code: Select all
SclRvRuler22.BottomMargin:=Shift * SclRvRuler22.ScreenRes div 96;
Re: Moving SclRvRuler1.BottomMargin by code
Thank you. I will do that.
you are as always very brilliant...
you are as always very brilliant...