::: µ¨ÆÄÀÌ Tip&Trick :::

µ¨ÆÄÀÌ Tip&Trick ¼º°Ý¿¡ ¸ÂÁö ¾Ê´Â ±¤°í,ºñ¹æ,Áú¹®ÀÇ ±ÛÀº Áï½Ã »èÁ¦Çϸç
³»¿ëÀ» º¹»çÇÏ¿© »ç¿ëÇÒ °æ¿ì ¹Ýµå½Ã ÀÌ°÷(http://www.howto.pe.kr)À» Ãâó·Î ¸í½ÃÇÏ¿© ÁÖ¼¼¿ä


Category

  ±è¿µ´ë(2003-03-07 10:31:41, Hit : 4337, Vote : 1599
 RichEdit ÀÇ ³»¿ëÀ» Bitmap À¸·Î ¸¸µé±â 2

Yes, you can use the EM_FORMATRECT message to get the richedit to paint
its contents onto any canvas. Only take care to use TrueType fonts for
the control, with other fonts the scaling of the outout canvas will
sometimes not work properly. Here is an example:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    Image1: TImage;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses printers, richedit;
{$R *.DFM}


procedure TForm1.Button1Click(Sender: TObject);
var
  zoomfactor, xScale, yScale: Single;
  pagerect, outputrect  : TRect;
  fmtRange: TFormatRange;
begin
  zoomfactor := 0.5;
  xScale := Screen.PixelsPerInch / GetDeviceCaps( Printer.handle, LOGPIXELSX );
  yScale := Screen.PixelsPerInch / GetDeviceCaps( Printer.handle, LOGPIXELSY );
  // Size bitmap to 50% of size of a printer page and fill it white
  With image1.Picture.Bitmap Do
  Begin
    Width := Round( Printer.Pagewidth  * zoomfactor * xScale );
    Height:= Round( Printer.PageHeight * zoomfactor * yScale );
    With Canvas Do
    Begin
      Brush.Color := clWhite;
      Brush.Style := bsSolid;
      FillRect( Cliprect );
    End;
  End;

  // scale the bitmap canvas according to the zoomfactor
  With image1.Picture.Bitmap.Canvas Do
  Begin
    SetMapMode( handle, MM_ANISOTROPIC );
    SetWindowExtEx(handle,
                   Screen.PixelsPerInch, Screen.PixelsPerInch,
                   Nil);
    SetViewportExtEx(handle,
                   Round(Screen.PixelsPerInch * zoomfactor),
                   Round(Screen.PixelsPerInch * zoomfactor),
                   Nil);
  End;

  // set up a page rectangle for the rich edit control and
  // an output area inside, which gives us some margins. The
  // units here are twips (1/1440 inch).
  With image1.Picture.Bitmap Do
    pagerect := Rect( 0, 0,
                      Round(width * 1440 / Screen.PixelsPerInch / xScale),
                      Round(height * 1440 / Screen.PixelsPerInch / yScale) );
  outputrect := pagerect;
  InflateRect( outputrect, -720, -720 ); // 1/2 inch margin

  // set up the parameter record for EM_FORMATRANGE
  fillChar( fmtRange, sizeof(fmtrange), 0);
  With fmtRange Do
  Begin
    hDC := image1.Picture.Bitmap.Canvas.Handle;
    hdcTarget := hDC;
    rc := outputrect;
    rcPage := pagerect;
    chrg.cpMin := 0;
    chrg.cpMax := richedit1.GetTextLen-1;
  End;

  // format the text
  richedit1.Perform( EM_FORMATRANGE, 1, Longint(@fmtRange));
  // Free cached information
  richedit1.Perform( EM_FORMATRANGE, 0, 0);
end;

end.





691   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] QReport ¸¦ bmp ·Î º¯È¯ÇÏ±â  ±è¿µ´ë 2003/03/07 3715 977
690   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] QReport¿¡¼­ Ãâ·ÂµÈ ÀڷḦ TextÈ­ÀÏ·Î ÀúÀå  ±è¿µ´ë 2003/03/04 5113 1387
689   [µ¥ÀÌÅͺ£À̽º] Query.RecordCount = -1  ±è¿µ´ë 2003/03/07 5753 1354
688   [µ¥ÀÌÅͺ£À̽º] QueryÇÑ °á°ú¸¦ ¼öÁ¤Çϱâ...  ±è¿µ´ë 2003/03/07 5415 1349
687   [¾Ë°í¸®Áò] Quick Sort algorithm  ±è¿µ´ë 2003/03/06 3656 1066
686   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] QuickReport¿¡¼­ ÇÁ¸°ÅÍ ¹Ù²Ù¾î¼­ Ãâ·ÂÇÏ±â  ±è¿µ´ë 2003/03/06 7215 1744
685   [³×Æ®¿÷/ÀÎÅͳÝ] Read/Write to COM Port  ±è¿µ´ë 2003/03/07 5616 1373
684   [½Ã½ºÅÛ] reboot 95/98/NT  ±è¿µ´ë 2003/03/07 5093 1448
683   [À©µµ¿ìÁî API] reboot Windows  ±è¿µ´ë 2003/03/07 5088 1338
682   [µ¥ÀÌÅͺ£À̽º] Record Lock °Ë»ç  ±è¿µ´ë 2003/03/07 4799 1267
681   [µ¥ÀÌÅͺ£À̽º] Record number for SQL Query in DBGrid #1  ±è¿µ´ë 2003/03/05 5385 1262
680   [µ¥ÀÌÅͺ£À̽º] Record number for SQL Query in DBGrid #2  ±è¿µ´ë 2003/03/05 5121 1275
679   [½Ã½ºÅÛ] Redirecting DOS Application Output  ±è¿µ´ë 2003/03/06 6955 1457
678   [COM/OLE] Registering *.tlb files without Delphi  ±è¿µ´ë 2003/03/06 7298 1272
677   [À©µµ¿ìÁî API] Resize °¡´ÉÇÑ Caption Bar ¾ø´Â Æû ¸¸µé±â  ±è¿µ´ë 2003/03/05 5384 1217
676   [³×Æ®¿÷/ÀÎÅͳÝ] RFC: Request for Comments  ±è¿µ´ë 2003/03/05 8337 2209
675   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit 2.0 ÁÙ°£°Ý Á¶Á¤  ±è¿µ´ë 2005/02/11 9495 1556
674   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit ¿¡ tab ¼³Á¤ÇÏ±â  ±è¿µ´ë 2003/03/07 4846 1297
673   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit ¿¡ URL link ¸¸µé±â  ±è¿µ´ë 2004/08/04 6712 1615
672   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit ¿¡¼­ ¹®ÀÚ(¿­)¸¦ ã¾Æ ±ÛÀÚ¼Ó¼º ¹Ù²Ù±â  ±è¿µ´ë 2003/03/06 5371 1341
671   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit ¿¡¼­ Ä¿¼­¸¦ óÀ½, ¸¶Áö¸·À¸·Î º¸³»±â  ±è¿µ´ë 2003/03/06 7664 1661
670   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit ÀÇ ³»¿ëÀ» Bitmap À¸·Î ¸¸µé±â  ±è¿µ´ë 2003/03/06 3889 1020
  [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit ÀÇ ³»¿ëÀ» Bitmap À¸·Î ¸¸µé±â 2  ±è¿µ´ë 2003/03/07 4337 1599
668   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit ÀÇ ¸¶¿ì½º Ä¿¼­ ¾Æ·¡ÀÇ ±ÛÀÚ ±¸ÇÏ±â  ±è¿µ´ë 2004/07/27 5304 1253
667   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit È­¸é¿¡ º¸¿©Áö´Â ù¹ø°/¸¶Áö¸· Çà¹øÈ£  ±è¿µ´ë 2003/03/07 6101 1596
666   [À©µµ¿ìÁî API] RichEdit¿¡ ÀÔ·ÂÇÑ ¹®ÀåÀÇ ½ÇÁ¦ ³ôÀÌ ±¸ÇÏ±â  ±è¿µ´ë 2003/03/06 5775 1620
665   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit¿¡¼­ HTML ű׸¦ ´Ù¸¥»öÀ¸·Î Ç¥½ÃÇÏ±â  ±è¿µ´ë 2003/03/07 6383 1460
664   [À©µµ¿ìÁî API] RichEdit¿¡¼­ URLÀ» HyperLink ·Î Ç¥½ÃÇÏ±â  ±è¿µ´ë 2003/03/31 6373 1517
663   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEditÀÇ ¿ÞÂÊ¿¡ ¿©À¯(margin) µÎ±â  ±è¿µ´ë 2003/03/05 6705 1786
662   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEditÀÇ Æ¯Á¤ À§Ä¡ÀÇ ±ÛÀÚ ¼Ó¼º ¹Ù²Ù±â  ±è¿µ´ë 2003/03/05 6970 1844
661   [½Ã½ºÅÛ] ROM-BIOS Á¤º¸ ÀÐ±â  ±è¿µ´ë 2003/03/07 6199 1525
660   [³×Æ®¿÷/ÀÎÅͳÝ] RS232 Åë½Å  ±è¿µ´ë 2003/03/07 7588 2018
659   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] Ruler ÄÞÆ÷³ÍÆ®(·¹Æ÷Æ® µðÀÚÀÎ,¿¡µðÅÍ¿¡¼­ »ç¿ë°¡´É)  ±è¿µ´ë 2003/03/05 4296 1169
658   [µ¥ÀÌÅͺ£À̽º] Save DBGrid To Excel  ±è¿µ´ë 2003/03/06 7909 2385
657   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ScrollBox ¿¡ ¹è°æ±×¸² ³Ö±â  ±è¿µ´ë 2003/03/14 4481 1209
656   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] Search and Select  ±è¿µ´ë 2004/08/03 6408 1750
655   [³×Æ®¿÷/ÀÎÅͳÝ] Sending Raw IP Packets  ±è¿µ´ë 2003/03/07 7871 2010
654   [³×Æ®¿÷/ÀÎÅͳÝ] Serial Port »ç¿ëÇÏ±â  ±è¿µ´ë 2003/03/07 7490 1907
653   [½Ã½ºÅÛ] Shareware ÇÁ·Î±×·¥ ¸¸µé±â - »ç¿ëȽ¼ö Á¦ÇÑ  ±è¿µ´ë 2003/03/05 6564 1786
652   [¾Ë°í¸®Áò] Shell Sort algorithm  ±è¿µ´ë 2003/03/06 6320 1898

[1][2][3][4][5][6][7] 8 [9][10]..[25] [´ÙÀ½ 10°³]
 

Copyright 1999-2025 Zeroboard / skin by zero