trichview.com

trichview.support




Re: How to reach WYSIWYG


Return to index


Author

Message

Sergey Tkachenko

Posted: 01/29/2002 13:25:53


Unfortunately, this is almost impossible until I'll implement a true

WYSIWYG.

But some approximate calculations are possible (approximate - because fonts

in different resolutions (on screen and printer) may differ).


The procedure below returns width and height of printable area converted to

the screen resolution.

If you assign returned Width to MinTextWidth and MaxTextWidth, lines will

wrap on the screen almost like on the paper.


procedure GetScreenPageSize(RVPrint: TRVPrint;

                            var Width, Height: Integer);

var DC: HDC;

    phoX, phoY, phW, phH, lpy, lpx, LM, TM, RM, BM: Integer;

begin

  DC := RV_GetPrinterDC; // from PtblRV unit


  Width  := GetDeviceCaps(DC, HORZRES);

  Height := GetDeviceCaps(DC, VERTRES);


  lpy := GetDeviceCaps(DC, LOGPIXELSY);

  lpx := GetDeviceCaps(DC, LOGPIXELSX);


  phoX := GetDeviceCaps(DC, PHYSICALOFFSETX);

  phoY := GetDeviceCaps(DC, PHYSICALOFFSETY);

  phW  := GetDeviceCaps(DC, PHYSICALWIDTH);

  phH  := GetDeviceCaps(DC, PHYSICALHEIGHT);


  if phW>phoX+Width then

    phW := phoX+Width;

  if phH>phoY+Height then

    phH := phoY+Height;


  LM := MulDiv(RVPrint.LeftMarginMM,   5*lpx, 127)- phoX;

  TM := MulDiv(RVPrint.TopMarginMM,    5*lpy, 127)- phoY;

  RM := MulDiv(RVPrint.RightMarginMM,  5*lpx, 127)- (phW-(phoX+Width));

  BM := MulDiv(RVPrint.BottomMarginMM, 5*lpy, 127)- (phH-(phoY+Height));


  if LM<0 then LM := 0;

  if TM<0 then TM := 0;

  if RM<0 then RM := 0;

  if BM<0 then BM := 0;


  dec(Width, LM+RM);

  dec(Height, TM+BM);


  DeleteDC(DC);


  DC := GetDC(0);


  Width  := MulDiv(Width,  GetDeviceCaps(DC, LOGPIXELSX), lpx);

  Height := MulDiv(Height, GetDeviceCaps(DC, LOGPIXELSY), lpy);


  ReleaseDC(0, DC);

end;




"Simon Leung" <simon@asiapro.net> ???????/???????? ? ???????? ?????????:

news:3c560f3d@support.torry.net...

> I am using RichViewEdit to write an editor, but it is difficult to control

> the width of area for edit such that the print out is same as my document.

I

> need to use the preview function to adjust the document's layout each

time.

> I have use the maxtextwidth and mintextwidth to control the wordswap but

it

> is difficult to set for different kinds of fonts.

>

> Are there any method can help me easily to adjust the editor like MsWord?

>

> Yours,

> Simon.

>

>





Powered by ABC Amber Outlook Express Converter