Setting margins at runtime
Fulcrum
Australia
Hi,
I have played with the labels demo file and I am getting the hang of everything.
I can adjust the number of columns and everything is working there.
My problem is setting the top margin. In the report designer I switched it to accept MM instead of pixels for all the measurements. At runtime in the PageHeaderBand OBP event I am setting the height of the band to equal a value passed in. That only sort of works.
It happily sets the top margin, but it seems to set it in pixels, not MM.
Is there a function to use to convert a MM value passed in as a variable into a pixel value?
The code I am currently using is this:
If I pass in 50 it leaves about 20mm, if I pass in 100 it leaves about 40mm. That is what makes me think that it is ignoring my chosen value type and reverting to pixels.
Any help on this would be appreciated.
I have played with the labels demo file and I am getting the hang of everything.
I can adjust the number of columns and everything is working there.
My problem is setting the top margin. In the report designer I switched it to accept MM instead of pixels for all the measurements. At runtime in the PageHeaderBand OBP event I am setting the height of the band to equal a value passed in. That only sort of works.
It happily sets the top margin, but it seems to set it in pixels, not MM.
Is there a function to use to convert a MM value passed in as a variable into a pixel value?
The code I am currently using is this:
PageHeader1.Height := MyTopMargin;
If I pass in 50 it leaves about 20mm, if I pass in 100 it leaves about 40mm. That is what makes me think that it is ignoring my chosen value type and reverting to pixels.
Any help on this would be appreciated.
Comments
but to set top margin of designpage.
less drift from rounding errors on long page runs.
procedure TForm1.Button1Click(Sender: TObject);
var
// declare variables of these types
v: TfrView;
b: TfrBandView;
Page: TfrPage;
begin
// you may want to set any of the tfrreport component's properties here.
// if you want to change the default settings.
frReport1.Pages.Clear; // clear any pages
frReport1.Pages.Add; // create page of default type ptreport
Page := frReport1.Pages[0]; // point page variable to 1st page of 0 based pages array
Page.Prop := poportrait; // printers must be in uses clause
page.UseMargins := true;
page.pgMargins.Top := 50;// integer in pixels
Is there any set function to use to calculate how many pixels to use? I presume there is as FastReports can use MM or inches throughout it.
I don't want the user to have to guess too much in setting it up. I just want them to type in a value. I presume that the pixels per MM or inch could cary from system to system, or is there a simple constant value to use?
Thanks again for any help in this.
If I read the width of the page (in pixels) from the report and I know the width in mm or inches, then I should be able to figure it out myself.
The only glitch with this, without trying it, is that the PageWidth value returns a smaller page size that the actual page. I'll have to do some experimenting.
I also need more than 2 hours sleep, but we can't have everything can we?
any how screen 800x600 is usually 96 pixels per inch.
fr is not perfect wysiwig there is rounding errors.
get some sleep things always look better with a clear head.
I have just encountered same problem because I wanted to shift some memo fields for specified number of centimeters and needed some time to realize what have happened.
I have solved it by putting blank memo field of size 1 x 1 cm, and then when I set dimensions at run time I just multiply desired dimension in centimeters with width/height of my Memo1cm.