ULiveDraw.pas
上传用户:raido2005
上传日期:2022-06-22
资源大小:5044k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. //*******************************************************//
  2. //                                                       //
  3. //                      DelphiFlash.com                  //
  4. //              Copyright (c) 2004 FeatherySoft, Inc.    //
  5. //                    info@delphiflash.com               //
  6. //                                                       //
  7. //*******************************************************//
  8. //  Description: live drawing on FlashCanvas
  9. //  Last update: 29 oct 2004
  10. unit ULiveDraw;
  11. interface
  12. uses
  13.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  14.   Dialogs, ExtCtrls, FlashPlayerControl, FlashCanvasControl, StdCtrls;
  15. type
  16.   TForm4 = class(TForm)
  17.     Panel1: TPanel;
  18.     Flash: TFlashCanvasControl;
  19.     RGType: TRadioGroup;
  20.     procedure FlashMouseDown(Sender: TObject;
  21.       Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  22.     procedure FormCreate(Sender: TObject);
  23.     procedure FlashMouseUp(Sender: TObject;
  24.       Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  25.     procedure FlashMouseMove(Sender: TObject;
  26.       Shift: TShiftState; X, Y: Integer);
  27.   private
  28.     { Private declarations }
  29.   public
  30.     PStart: TPoint;
  31.     isDown: boolean;
  32.   end;
  33. var
  34.   Form4: TForm4;
  35. implementation
  36. {$R *.dfm}
  37. procedure TForm4.FlashMouseDown(Sender: TObject;
  38.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  39. begin
  40.   PStart.X := X;
  41.   PStart.Y := Y;
  42.   isDown := true;
  43. end;
  44. procedure TForm4.FormCreate(Sender: TObject);
  45. begin
  46.   isDown := false;
  47. end;
  48. procedure TForm4.FlashMouseUp(Sender: TObject;
  49.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  50. begin
  51.   isDown := false;
  52. end;
  53. procedure TForm4.FlashMouseMove(Sender: TObject;
  54.   Shift: TShiftState; X, Y: Integer);
  55. begin
  56.   if isDown then
  57.     begin
  58.       With Flash.FlashCanvas do
  59.         begin
  60.           Clear;
  61.           Case RGType.ItemIndex of
  62.            0:begin
  63.               Pen.Color := clBlue;
  64.               MoveTo(PStart.X, PStart.Y);
  65.               LineTo(X, Y);
  66.              end;
  67.            1:begin
  68.               Pen.Color := clGreen;
  69.               Rectangle(PStart.X, PStart.Y, X, Y);
  70.              end;
  71.            2:begin
  72.               Pen.Color := clRed;
  73.               Ellipse(PStart.X, PStart.Y, X, Y);
  74.              end;
  75.           end;
  76.         end;
  77.       Flash.UpdateCanvas;
  78.     end;
  79. end;
  80. end.