How to set print margin???

I need to print the content of the RichEdit; how can I set the margin when print??  By default, the RichEdit.Print use the printer's default margin, how can I change that???
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Do something like this:

  RichEdit1.PageRect :=
    Rect(MyLeftMargin, 0, Printer.PageHeight, Printer.PageWidth);

The values are set in pixels. This means that you have to watch
the pixelsperinch property.

In comctrls.pas (written by Borland) it is used like this:

procedure TCustomRichEdit.Print(const Caption: string);
  Range: TFormatRange;
  LastChar, MaxLen, LogX, LogY: Integer;
  FillChar(Range, SizeOf(TFormatRange), 0);
  with Printer, Range do
    LogX := GetDeviceCaps(Handle, LOGPIXELSX);
    LogY := GetDeviceCaps(Handle, LOGPIXELSY);
    hdc := Handle;
    hdcTarget := hdc;
    if IsRectEmpty(PageRect) then
      rc.right := PageWidth * 1440 div LogX;
      rc.bottom := PageHeight * 1440 div LogY;
    else begin
      rc.left := PageRect.Left * 1440 div LogX; := PageRect.Top * 1440 div LogY;
      rc.right := PageRect.Right * 1440 div LogX;
      rc.bottom := PageRect.Bottom * 1440 div LogY;
    rcPage := rc;
    Title := Caption;
    LastChar := 0;
    MaxLen := GetTextLen;
    chrg.cpMax := -1;
      chrg.cpMin := LastChar;
      LastChar := SendMessage(Self.Handle, EM_FORMATRANGE, 1, Longint(@Range));
      if (LastChar < MaxLen) and (LastChar <> -1) then NewPage;
    until (LastChar >= MaxLen) or (LastChar = -1);
  SendMessage(Handle, EM_FORMATRANGE, 0, 0);

You'll figure it out!

/// John


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hhoAuthor Commented:
For some reason this doesn't work on Windows NT 4.0.
The problem is that RichEdit can't even print in NT.
Any clue?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.