home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Books / 2 / ROTATE.ZIP / TEXTROT1.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1996-07-29  |  1.7 KB  |  70 lines

  1. unit Textrot1;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
  12.       Shift: TShiftState; X, Y: Integer);
  13.   private
  14.     { Private-Deklarationen }
  15.   public
  16.     { Public-Deklarationen }
  17.   end;
  18.  
  19. var
  20.   Form1: TForm1;
  21.  
  22. implementation
  23.  
  24. {$R *.DFM}
  25. procedure CanvasSetAngle(C: TCanvas; A: Single);
  26. var
  27.   LogRec: TLOGFONT;     {Font informationen}
  28. begin
  29.   GetObject(C.Font.Handle,SizeOf(LogRec),Addr(LogRec));
  30.   LogRec.lfEscapement := Trunc(A*10);
  31.   C.Font.Handle := CreateFontIndirect(LogRec);
  32. end;
  33.  
  34. (*procedure CanvasTextOutAngle(C: TCanvas; x,y: Integer; A: Word; S: string);
  35. var
  36.   LogRec: TLOGFONT;
  37.   FHandleOld, FHandleNew: HFONT;
  38. begin
  39.   GetObject(C.Font.Handle, SizeOf(LogRec), Addr(LogRec));
  40.   LogRec.lfEscapement := d;
  41.  
  42.   {* Create a new font handle using the modified old font handle *}
  43.   NewFontHandle := CreateFontIndirect(LogRec);
  44.  
  45.   {* Save the old font handle! We have to put it back when we are done! *}
  46.   OldFontHandle := SelectObject(c.Handle,NewFontHandle);
  47.  
  48.   {* Finally. Output the text! *}
  49.   c.TextOut(x,y,s);
  50.  
  51.   {* Put the font back the way we found it! *}
  52.   NewFontHandle := SelectObject(c.Handle,OldFontHandle);
  53.  
  54.   {* Delete the temporary (NewFontHandle) that we created *}
  55.   DeleteObject(NewFontHandle);
  56.  
  57. end; {* CanvasTextOutAngle *}
  58. *)
  59. procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  60.   Shift: TShiftState; X, Y: Integer);
  61. Var A: Integer;
  62. begin
  63.    A := Random(3600);
  64.    CanvasSetAngle(Canvas, A / 10);
  65.    Canvas.RectAngle(X-1,Y-1,X+1,Y+1);
  66.    Canvas.TextOut(x, Y, FormatFloat('##0.0', A/10)+'░');
  67. end;
  68.  
  69. end.
  70.