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

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


Category

  ±è¿µ´ë(2003-03-07 20:08:00, Hit : 3196, Vote : 809
 TMemo ¸¦ È­¸éÅ©±â·Î ÀμâÇϱâ

{+------------------------------------------------------------
| Procedure PrintMemo
|
| Parameters:
| aMemo: memo to print
| centerVertical: true if output should be centered vertically
| centerHorizontal: true if output should be centered horizontally
| Call method:
| static
| Description:
| Prints the contents of a memo on the currently selected
| printer, using the memos Font. The output can be centered
| vertically and/or horizontally. Default margins will be used.
| If the text does not fit onto one page the centerVertical
| parameter is ignored.
| Error Conditions:
| none
| Note:
| requires Printers in the Uses clause.
|Created: 27.10.97 13:16:46 by P. Below
+------------------------------------------------------------}
Procedure TPostForm.PrintMemo( aMemo: TMemo;
                     centerVertical, centerHorizontal: Boolean );
Var
  topMargin, bottomMargin, leftMargin, rightMargin: Integer;
  x,y: Integer;
  maxLineLength: Integer;
  linecounter: Integer;
  lineheight : Integer;
Begin
  { Set the default margins to 1 inch for top, bottom, 0.75 inch
    for left and right margins. GetDeviceCaps is used to get the
    printers resolution (dots per inch). The margin variables
    contain the position of the margin on paper, in dots, not the
    distance from the border of the printing region! }
  topMargin := GetDeviceCaps( Printer.Handle, LOGPIXELSY );
  bottomMargin := Printer.PageHeight - topMargin;

  leftMargin := GetDeviceCaps( Printer.handle, LOGPIXELSX ) * 3 div 4;
  rightMargin := Printer.PageWidth - leftMargin;

  { Start the print job, assign the memo font to the printer canvas.
    Note that we have to make sure the print job is closed properly,
    thus the try finally block. }
  Printer.BeginDoc;
  try
    Printer.Canvas.Font.PixelsPerInch :=
      GetDeviceCaps( Printer.Canvas.Handle, LOGPIXELSY );
      { This is really only necessary for Delphi 1, due to a
        buglet. }
    Printer.Canvas.Font:= aMemo.Font;

    { Determine the height of a line in pixels }
    lineHeight := Printer.Canvas.TextHeight('Ay');

    If centerHorizontal Then Begin
      { Iterate once over all lines of the memo and determine the
        length, in pixels, of the longest line. We need that to
        adjust the leftMargin to center the text. }
      maxLineLength := 0;
      For linecounter := 0 To aMemo.Lines.Count-1 Do Begin
        x:= Printer.Canvas.TextWidth( aMemo.Lines[linecounter]);
        If x > maxLineLength Then
          maxLineLength := x;
      End; { For }

      { Adjust the leftMargin to center the text into the
        available space between the current margins. }
      x := leftMargin +
           (rightMargin-leftMargin-maxLineLength) div 2;
      If x < leftMargin Then Begin
        { Problem, longest line does not fit into the available
          space! We leave the margin untouched, the line will
          be truncated. }
      End { If }
      Else
        leftMargin := x;
    End; { If }

    If centerVertical Then Begin
      { Calculate the vertical space needed to print all lines,
        adjust the topMargin to center the text as needed. }
      y := lineHeight * aMemo.Lines.Count;
      If y < (bottomMargin - topMargin) Then Begin
        topMargin :=
          topMargin + (bottomMargin - topMargin - y) div 2;
      End; { If }
      { Else
          space needed is larger than the height of a page,
          so ignore the center request. }
    End; { If }

    { Margins have been calculated, so we are finally set up
      to start printing lines. In the following code x and y
      hold the starting position of the next line. }
    x:= leftMargin;
    y:= topMargin;
    For linecounter := 0 To aMemo.Lines.Count-1 Do Begin
      Printer.Canvas.TextOut( x, y, aMemo.Lines[linecounter]);
      y := y + lineHeight;
      If y >= bottomMargin Then Begin
        { Eject the page and start a new one, but only if
          the line we have just printed is not the last line
          anyway. EndDoc will eject the current page. }
        If linecounter < (aMemo.Lines.Count-1) Then Begin
          Printer.NewPage;
          y:= topMargin;
        End;
      End; { If }
    End; { For }
  finally
    Printer.EndDoc;
  end;
End; { PrintMemo }





491   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] TRichEdit ÀÇ ¼±ÅÃµÈ ¿µ¿ª¸¸ ÀμâÇÏ±â  ±è¿µ´ë 2003/03/07 5043 937
490   [½Ã½ºÅÛ] CPU Á¾·ù ±¸ÇÏ±â  ±è¿µ´ë 2003/03/07 5395 1388
489   [½Ã½ºÅÛ] »ç¿îµåÆÄÀÏ ¾øÀÌ PC ½ºÇÇÄ¿·Î À½¾Ç¿¬ÁÖ  ±è¿µ´ë 2003/03/07 7604 1138
488   [³×Æ®¿÷/ÀÎÅͳÝ] ÇÁ·Î±×·¥À¸·Î ³×Æ®¿öÅ© µå¶óÀÌºê ¿¬°á/ÇØÁ¦  ±è¿µ´ë 2003/03/07 7428 1428
487   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] À©µµ¿ìÁî Á¾·á¿Í °°Àº ±×´ÃÁø È­¸é ¸¸µé±â  ±è¿µ´ë 2003/03/07 3551 946
486   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ¾ÆÀÌÄÜ »çÀÌÆ®  ±è¿µ´ë 2003/03/07 4070 1209
485   [½Ã½ºÅÛ] À©µµ¿ìÁî ½Ã½ºÅÛ Ç¥ÁØ ÆùÆ® ±¸ÇÏ±â  ±è¿µ´ë 2003/03/07 3484 967
484   [³×Æ®¿÷/ÀÎÅͳÝ] RS232 Åë½Å  ±è¿µ´ë 2003/03/07 7591 2020
483   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ÁÖ¾îÁø ¿µ¿ªÀÇ È­¸é ĸó  ±è¿µ´ë 2003/03/07 3926 1119
482   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ¼ýÀÚ¸¦ ¿µ¹® Ç¥±â·Î ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 4693 1044
481   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ¼ýÀÚ¸¦ ÇÑ±Û Ç¥±â·Î ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 4029 1056
480   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] RichEdit ÀÇ ³»¿ëÀ» Bitmap À¸·Î ¸¸µé±â 2  ±è¿µ´ë 2003/03/07 4347 1610
479   [COM/OLE] MS-WORD Á¾·á½ÃÅ°±â  ±è¿µ´ë 2003/03/07 3044 853
478   [À©µµ¿ìÁî API] ½Ã½ºÅÛ »ç¿îµå ¿¬ÁÖÇÏ±â  ±è¿µ´ë 2003/03/07 5353 1455
477   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] Algorithm to sort a TStringGrid #2  ±è¿µ´ë 2003/03/07 5291 1375
476   [À©µµ¿ìÁî API] ¿ÜºÎ ÇÁ·Î±×·¥ÀÇ ÁÂÇ¥,»óÅ ±¸ÇÏ±â  ±è¿µ´ë 2003/03/07 3672 1155
475   [À©µµ¿ìÁî API] À©µµ¿ìÁî Telnet À¸·Î È£½ºÆ® Á¢¼ÓÇÏ±â  ±è¿µ´ë 2003/03/07 4564 1247
474   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ƯÁ¤ÇÑ Æú´õ·Î À̵¿ÇÑ DOS â ¶ç¿ì±â  ±è¿µ´ë 2003/03/07 4649 1256
473   [½Ã½ºÅÛ] DOS ¸í·É¾î ½ÇÇàÇÏ°í °á°ú ¹Þ¾Æ¿À±â  ±è¿µ´ë 2003/03/07 7162 1680
472   [À©µµ¿ìÁî API] NTÀÇ ÇöÀç user°¡ administrative privilege ¸¦ °¡Áö°í ÀÖ´ÂÁö?  ±è¿µ´ë 2003/03/07 3541 966
471   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] µÎ°³ÀÇ StringGrid sync ¸¶Ãß±â  ±è¿µ´ë 2003/03/07 4125 1132
470   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] À©µµ¿ìÀÇ title bar ÆùÆ® ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 3649 960
469   [³×Æ®¿÷/ÀÎÅͳÝ] ³×Æ®¿öÅ© °øÀ¯ ¼³Á¤/ÇØÁ¦ Çϱâ (Windows 9x)  ±è¿µ´ë 2003/03/07 4878 1229
468   [³×Æ®¿÷/ÀÎÅͳÝ] ³×Æ®¿öÅ© °øÀ¯ Á¤º¸ Àоî¿À±â (WIndows 9x)  ±è¿µ´ë 2003/03/07 4130 1154
467   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ´­·ÁÁø Å°º¸µå Å°ÀÇ ¸íĪ ±¸ÇÏ±â  ±è¿µ´ë 2003/03/07 7879 1583
466   [À©µµ¿ìÁî API] Windows98 ¿¡¼­ÀÇ SetForegroundWindow  ±è¿µ´ë 2003/03/07 6390 1664
465   [À©µµ¿ìÁî API] Task bar ¿¡ ³ªÅ¸³ªÁö ¾Ê´Â ÇÁ·Î±×·¥ ¸¸µé±â  ±è¿µ´ë 2003/03/07 5663 1660
464   [COM/OLE] Outlook »ç¿ëÇÏ±â  ±è¿µ´ë 2003/03/07 4047 1335
463   [½Ã½ºÅÛ] ÁöÁ¤ÇÑ drive°¡ CD-ROM ÀÎÁö °Ë»çÇÏ±â  ±è¿µ´ë 2003/03/07 6905 1820
462   [½Ã½ºÅÛ] ¾î¶² ¾îÇø®ÄÉÀ̼ÇÀÌ ½ÃÀÛ µÇ´ÂÁö hookÀ¸·Î ¾Ë¾Æ³»±â  ±è¿µ´ë 2003/03/07 5787 1729
461   [À©µµ¿ìÁî API] À©µµ¿ìÁî Ž»ö±âÀÇ ¾ÆÀÌÄÜ »Ì¾Æ³»¼­ »ç¿ëÇÏ±â  ±è¿µ´ë 2003/03/07 8602 2063
460   [À©µµ¿ìÁî API] System Images  ±è¿µ´ë 2003/03/07 8529 1986
459   [À©µµ¿ìÁî API] ÄÄÇ»ÅÍ/ÆÄÀÏ/Æú´õ ã±â È­¸é ¶ç¿ì±â  ±è¿µ´ë 2003/03/07 8552 1696
458   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] Unix-format time À» TDateTime ·Î ¹Ù²Ù±â  ±è¿µ´ë 2003/03/07 4504 1240
457   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] ½ÇÇà½Ã component ¸¦ Move/Resize ½ÃÅ°±â  ±è¿µ´ë 2003/03/07 3692 1067
  [ÀϹÝ/ÄÄÆ÷³ÍÆ®] TMemo ¸¦ È­¸éÅ©±â·Î ÀμâÇÏ±â  ±è¿µ´ë 2003/03/07 3196 809
455   [ÀϹÝ/ÄÄÆ÷³ÍÆ®] SpeedButton ¿¡ OnMouseEnter/OnMouseExit À̺¥Æ® ³Ö±â  ±è¿µ´ë 2003/03/07 4373 1183
454   [À©µµ¿ìÁî API] Å°º¸µåÀÇ Scroll Lock Äѱâ/²ô±â  ±è¿µ´ë 2003/03/07 4754 1276
453   [µ¥ÀÌÅͺ£À̽º] table packing ÇÏ±â  ±è¿µ´ë 2003/03/07 4040 1119
452   [À©µµ¿ìÁî API] reboot Windows  ±è¿µ´ë 2003/03/07 5108 1343

[ÀÌÀü 10°³] [1]..[11][12] 13 [14][15][16][17][18][19][20]..[25] [´ÙÀ½ 10°³]
 

Copyright 1999-2025 Zeroboard / skin by zero