unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, ComCtrls, ToolWin;
type
  {就这话}TDrawingTool=(dtLine,dtRectangle,dtEllipse,dtRoundRect,dtPolyLine,dtArc,dtChord,dtSelect,dtDrop,dtFill,dtZoom,dtPen,dtBrush,dtPentong,dtText,dtMove,dtErace);
  //private
  //public
end;
  TForm1 = class(TForm)
    ToolBar1: TToolBar;
    ToolButton1: TToolButton;
    ImgPicture: TImage;
    procedure ImgPictureMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ImgPictureMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure DrawFrame(Points:array of TPoint);
    procedure FormCreate(Sender: TObject);
  private
    Drawing:Boolean;
    Origin,MovePt:TPoint;
    DrawingTool:TDrawingTool;
    NoSelected:Boolean;
    SelectRect:TRect;
    { Private declarations }
  public
    BrushStyle:TPenStyle;
    BrushColor:TColor;
    BrushBitmap:TBitmap;
    PenStyle:TPenStyle;
    PenColor:TColor;
    PenWid:Integer;
    PenMode:TPenMode;
    BLineStyle,BLineWid:Ingeter;
    { Public declarations }
  end;
var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ImgPictureMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
Drawing:=true;
ImgPicture.Canvas.MoveTo(X,Y);
Origin:=Point(X,Y);
MoveToPT:=Point(X,Y);
end;
 
......
end.

解决方案 »

  1.   

    TDrawingTool=(dtLine,dtRectangle,dtEllipse,dtRoundRect,dtPolyLine,dtArc,dtChord,dtSelect,dtDrop,dtFill,dtZoom,dtPen,dtBrush,dtPentong,dtText,dtMove,dtErace);是一个枚举集定义dtLine      对应是 0
    dtRectangle 对应是 1
    ...
    依次类推使用该方法是使用程序能通俗易懂,试想想,程序中全是0,1,2这些数字,
    能猜出其实际意义吗?上面的代码就做到了
      

  2.   

    {就这话}TDrawingTool=(dtLine,dtRectangle,dtEllipse,dtRoundRect,dtPolyLine,dtArc,dtChord,dtSelect,dtDrop,dtFill,dtZoom,dtPen,dtBrush,dtPentong,dtText,dtMove,dtErace);
      //private
      //public
    end;        <--------- 这里是多余的