UnitPaintbrush.pas
上传用户:conquerdj
上传日期:2022-07-08
资源大小:417k
文件大小:27k
- unit UnitPaintbrush;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ImgList, ComCtrls, ToolWin, StdCtrls, ExtCtrls, Menus, Buttons,
- ExtDlgs,JPEG;
- type
- TFormPaintbrush = class(TForm)
- ToolBar1: TToolBar;
- ToolButtonLine: TToolButton;
- ToolButtonEllipse: TToolButton;
- ToolButtonFEllipse: TToolButton;
- ToolButtonRectangle: TToolButton;
- ToolButtonFRectangle: TToolButton;
- ToolButtonEraser: TToolButton;
- ToolButtonPen: TToolButton;
- ToolButtonArrow: TToolButton;
- ToolButtonEnlarge: TToolButton;
- ImageList1: TImageList;
- ComboBoxWidth: TComboBox;
- ColorBox: TColorBox;
- MainMenu1: TMainMenu;
- MenuFile: TMenuItem;
- MenuNew: TMenuItem;
- MenuSave: TMenuItem;
- MenuOpen: TMenuItem;
- MenuExit: TMenuItem;
- N6: TMenuItem;
- OpenPictureDialog1: TOpenPictureDialog;
- SavePictureDialog1: TSavePictureDialog;
- Panel1: TPanel;
- ToolButtonEC: TToolButton;
- ToolButtonChar: TToolButton;
- ButtonPicture: TButton;
- SpeedButtonDisplay: TSpeedButton;
- FontDialog1: TFontDialog;
- ToolButtonFont: TToolButton;
- SpeedButtonRouter: TSpeedButton;
- SpeedButtonSwitch: TSpeedButton;
- ToolBar2: TToolBar;
- ToolBar3: TToolBar;
- ToolButtonCut: TToolButton;
- ToolButtonEiminate: TToolButton;
- ToolButtonOpen: TToolButton;
- ToolButtonSave: TToolButton;
- ToolButtonHelp: TToolButton;
- SpeedButtonModem: TSpeedButton;
- SpeedButtonCDROM: TSpeedButton;
- SpeedButtonServer: TSpeedButton;
- SpeedButtonDB: TSpeedButton;
- SpeedButtonConcentrator: TSpeedButton;
- SpeedButton1: TSpeedButton;
- Shape1: TShape;
- M1: TMenuItem;
- N1: TMenuItem;
- MenuPen: TMenuItem;
- MenuChar: TMenuItem;
- procedure FormShow(Sender: TObject);
- procedure ToolButtonLineClick(Sender: TObject);
- procedure ToolButtonEllipseClick(Sender: TObject);
- procedure ToolButtonRectangleClick(Sender: TObject);
- procedure ComboBoxWidthChange(Sender: TObject);
- procedure ColorBoxChange(Sender: TObject);
- procedure ToolButtonFEllipseClick(Sender: TObject);
- procedure ToolButtonFRectangleClick(Sender: TObject);
- procedure ToolButtonPenClick(Sender: TObject);
- procedure ToolButtonCutClick(Sender: TObject);
- procedure MenuNewClick(Sender: TObject);
- procedure MenuSaveClick(Sender: TObject);
- procedure MenuOpenClick(Sender: TObject);
- procedure ToolButtonEraserClick(Sender: TObject);
- procedure ToolButtonArrowClick(Sender: TObject);
- procedure ToolButtonEnlargeClick(Sender: TObject);
- procedure ToolButtonEiminateClick(Sender: TObject);
- procedure MenuExitClick(Sender: TObject);
- procedure ToolButtonECClick(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure ButtonPictureClick(Sender: TObject);
- procedure SpeedButtonDisplayClick(Sender: TObject);
- procedure ToolButtonCharClick(Sender: TObject);
- procedure ToolButtonFontClick(Sender: TObject);
- procedure SpeedButtonRouterClick(Sender: TObject);
- procedure SpeedButtonSwitchClick(Sender: TObject);
- procedure ToolButtonHelpClick(Sender: TObject);
- procedure SpeedButtonModemClick(Sender: TObject);
- procedure SpeedButtonCDROMClick(Sender: TObject);
- procedure SpeedButtonServerClick(Sender: TObject);
- procedure SpeedButtonDBClick(Sender: TObject);
- procedure SpeedButtonConcentratorClick(Sender: TObject);
- procedure SpeedButton1Click(Sender: TObject);
- procedure MenuMainHelpClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- FormPaintbrush: TFormPaintbrush;
- //当前选择的工具
- mType : Integer;
- //当前正在绘制的图元线宽
- mDrawWidth : Integer;
- //当前正在绘制的图元颜色
- mDrawColor : TColor;
- //鼠标点击鼠标点击“放大镜”的次数
- mClick:Integer;
- //鼠标点击鼠标点击“切换黑白板”的次数
- mCNO:Integer;
- //鼠标点击鼠标点击“图片”的次数
- mCpno:Integer;
- //修改标志,以便提醒用户保存文档
- mModifyFlag : Bool;
- implementation
- uses UnitFormCanvas,UnitTxt,UnitHelp;
- {$R *.dfm}
- procedure ScreenCapture(Bmp: TBitmap);
- var
- DeskWnd: HWnd;
- DeskDC: HDC;
- DeskCv: TCanvas;
- R: TRect;
- W, H: Integer;
- begin
- if Bmp = nil then Exit;
- DeskWnd := GetDesktopWindow;
- //获得桌面句柄
- DeskDC := GetWindowDC(DeskWnd);
- //创建画布
- DeskCv := TCanvas.Create;
- //设置画布的句柄
- DeskCv.Handle := DeskDC;
- //获得屏幕尺寸
- //屏幕的宽
- W := Screen.Width;
- //屏幕的高
- H := Screen.Height;
- //整个屏幕区域
- R := Bounds(0, 0, W, H);
- try
- //设置Bmp
- Bmp.HandleType := bmDIB;
- Bmp.PixelFormat := pf24Bit;
- Bmp.Width := W;
- Bmp.Height := H;
- //设置拷贝模式
- Bmp.Canvas.CopyMode := cmSrcCopy;
- //把整个屏幕复制到BITMAP中
- Bmp.Canvas.CopyRect(R, DeskCv, R);
- finally
- //释放CANVAS对象
- DeskCv.Free;
- //释放DC
- ReleaseDC(DeskWnd, DeskDC);
- end;
- end;
- //响应屏幕画笔窗口的显示事件
- procedure TFormPaintbrush.FormShow(Sender: TObject);
- begin
- //设置窗口显示的位置
- FormPaintbrush.Left:=0;
- FormPaintbrush.Top:=100;
- //初始化变量
- mClick:=0;
- mCpno:=0;
- mCNO:=0;
- //将Panel1隐藏起来
- Panel1.Visible:=false;
- //字体工具变灰
- ToolButtonFont.Enabled:=false;
- //将桌面拷贝到 image1和Imagecopy中
- ScreenCapture(FormCanvas.image1.Picture.Bitmap);
- ScreenCapture(FormCanvas.Imagecopy.Picture.Bitmap);
- //显示画布窗口
- FormCanvas.Show;
- //响应工具按扭“铅笔”的单击事件
- ToolButtonPen.Click;
- end;
- //响应工具按扭“直线”的单击事件
- procedure TFormPaintbrush.ToolButtonLineClick(Sender: TObject);
- begin
- //设置当前选择的工具为1(1代表直线)
- mType:=1;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=true;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应工具按扭“椭圆”的单击事件
- procedure TFormPaintbrush.ToolButtonEllipseClick(
- Sender: TObject);
- begin
- //设置当前选择的工具为3(3代表椭圆)
- mType:=3;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=true;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应工具按扭“矩形”的单击事件
- procedure TFormPaintbrush.ToolButtonRectangleClick(Sender: TObject);
- begin
- //设置当前选择的工具为2(2代表矩形)
- mType:=2;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=true;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应复选框的改变事件
- procedure TFormPaintbrush.ComboBoxWidthChange(Sender: TObject);
- begin
- //线宽设置为复选框的内容
- mDrawWidth:=StrToInt(ComboBoxWidth.text);
- end;
- //响应颜色框的改变事件
- procedure TFormPaintbrush.ColorBoxChange(Sender: TObject);
- begin
- //颜色设置为颜色框所选择的颜色
- Shape1.Brush.Color:=ColorBox.Selected;
- //设置绘图的颜色
- mDrawColor:=Shape1.Brush.Color;
- //设置字体的颜色
- FormTxt.Edit1.Font.Color:=ColorBox.Selected;
- end;
- //响应工具按扭“带填充的椭圆”的单击事件
- procedure TFormPaintbrush.ToolButtonFEllipseClick(Sender: TObject);
- begin
- //设置当前选择的工具为4(4代表带填充的椭圆)
- mType:=4;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=true;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应工具按扭“带填充矩形”的单击事件
- procedure TFormPaintbrush.ToolButtonFRectangleClick(Sender: TObject);
- begin
- //设置当前选择的工具为5(5代表带填充的矩形)
- mType:=5;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=true;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应工具按扭“铅笔”的单击事件
- procedure TFormPaintbrush.ToolButtonPenClick(Sender: TObject);
- begin
- //设置当前选择的工具为6(6代表铅笔工具)
- mType:=6;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=true;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应工具按扭“切换黑白板”的单击事件
- procedure TFormPaintbrush.ToolButtonCutClick(Sender: TObject);
- begin
- //判断修改标志的状态,以提醒用户是否需要保存
- if(mModifyFlag=true)then
- begin
- //显示保存提示框
- if(MessageDlg('将改动保存到未命名?',
- mtConfirmation,[mbYes,mbNo],0) =mrYes) then
- //调用"保存"菜单的响应函数来保存文件
- MenuSaveClick(Sender);
- //设置修改状态
- mModifyFlag:=false;
- end;
- //鼠标点击"切换黑白板"按钮的次数自增1
- mCNO:=mCNO+1;
- if(mCNO mod 3=1) then
- begin
- //将image1的颜色设置为黑色
- FormCanvas.image1.Canvas.Brush.Color:=clblack;
- FormCanvas.image1.Canvas.FillRect(FormCanvas.image1.ClientRect);
- end
- else if(mCNO mod 3=2) then
- begin
- //将image1的颜色设置为白色
- FormCanvas.image1.Canvas.Brush.Color:=clwhite;
- FormCanvas.image1.Canvas.FillRect(FormCanvas.image1.ClientRect);
- end
- else
- //将image1恢复为原先的图片
- FormCanvas.image1.Picture:=FormCanvas.imagecopy.Picture;
- end;
- //响应"新建"菜单
- procedure TFormPaintbrush.MenuNewClick(Sender: TObject);
- begin
- //判断修改标志的状态,以提醒用户是否需要保存
- if(mModifyFlag=true)then
- begin
- //显示保存提示框
- if(MessageDlg('将改动保存到未命名?',
- mtConfirmation,[mbYes,mbNo],0) =mrYes) then
- //调用"保存"菜单的响应函数来保存文件
- MenuSaveClick(Sender);
- //设置修改状态
- mModifyFlag:=false;
- end;
- //将最先桌面的图片拷贝到image1中
- FormCanvas.image1.Picture:=FormCanvas.imagecopy.Picture;
- end;
- //响应"保存"菜单
- procedure TFormPaintbrush.MenuSaveClick(Sender: TObject);
- begin
- //显示保存图片对话框,并且单击“确定”按钮,则...
- if SavePictureDialog1.Execute() then
- begin
- //保存Image1图片
- FormCanvas.Image1.Picture.Bitmap.SaveToFile(SavePictureDialog1.fileName);
- //设置修改状态
- mModifyFlag:=false;
- end;
- end;
- //响应"打开"菜单
- procedure TFormPaintbrush.MenuOpenClick(Sender: TObject);
- var
- rect:Trect;
- begin
- //显示打开图片对话框
- if OpenPictureDialog1.Execute() then
- Bitmap.LoadFromFile(OpenPictureDialog1.Filename);
- rect.Left:=0;
- rect.Top:=0;
- rect.Right:=FormCanvas.Image1.Width;
- rect.Bottom:=FormCanvas.Image1.Height;
- //判断修改标志的状态,以提醒用户是否需要保存
- if(mModifyFlag=true)then
- begin
- //显示保存提示框
- if(MessageDlg('将改动保存到未命名?',
- mtConfirmation,[mbYes,mbNo],0) =mrYes) then
- //调用"保存"菜单的响应函数来保存文件
- MenuSaveClick(Sender);
- //设置修改状态
- mModifyFlag:=false;
- end;
- //将位图中的图象复制到画布中
- FormCanvas.Image1.Canvas.CopyRect(rect,bitmap.Canvas,rect);
- end;
- //响应工具按扭“橡皮”的单击事件
- procedure TFormPaintbrush.ToolButtonEraserClick(Sender: TObject);
- begin
- //设置当前选择的工具为为7(7代表橡皮工具)
- mType:=7;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=true;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crHandPoint;
- end;
- //响应工具按扭“箭头”的单击事件
- procedure TFormPaintbrush.ToolButtonArrowClick(Sender: TObject);
- begin
- //设置当前选择的工具为8(8代表箭头工具)
- mType:=8;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=true;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应工具按扭“放大镜”的单击事件
- procedure TFormPaintbrush.ToolButtonEnlargeClick(Sender: TObject);
- begin
- //响应的次数增1
- mClick:=mClick+1;
- if mClick mod 2=1 then
- begin
- //工具条的down状态(即是否下压)
- ToolButtonEnlarge.Down:=true;
- //显示Image2
- FormCanvas.Image2.Show;
- end
- else
- begin
- //工具条的down状态(即是否下压)
- ToolButtonEnlarge.Down:=false;
- //隐藏Image2
- FormCanvas.Image2.Hide;
- end;
- end;
- //响应工具按扭“清屏”的单击事件
- procedure TFormPaintbrush.ToolButtonEiminateClick(Sender: TObject);
- begin
- //显示清屏提示框
- //if(MessageDlg('确定要清空屏幕吗?',
- //mtConfirmation,[mbYes,mbNo],0) =mrYes) then
- begin
- //如果屏幕处于桌面状态,则恢复桌面图片
- if(mCNO mod 3=1) then
- begin
- FormCanvas.image1.Canvas.Brush.Color:=clblack;
- FormCanvas.image1.Canvas.FillRect(FormCanvas.image1.ClientRect);
- end
- //如果屏幕处于白板状态,则恢复白板
- else if(mCNO mod 3=2) then
- begin
- FormCanvas.image1.Canvas.Brush.Color:=clwhite;
- FormCanvas.image1.Canvas.FillRect(FormCanvas.image1.ClientRect);
- end
- //如果屏幕处于黑板状态就恢复黑板
- else
- FormCanvas.image1.Picture:=FormCanvas.imagecopy.Picture;
- end;
- end;
- //响应“退出”菜单
- procedure TFormPaintbrush.MenuExitClick(Sender: TObject);
- begin
- //关闭窗口
- close();
- end;
- //响应工具按扭“取色”的单击事件
- procedure TFormPaintbrush.ToolButtonECClick(Sender: TObject);
- begin
- //设置当前选择的工具为10(10代表取色工具)
- mType:=10;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=true;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- end;
- //响应窗口关闭事件
- procedure TFormPaintbrush.FormClose(Sender: TObject;
- var Action: TCloseAction);
- begin
- {
- //判断修改标志的状态,以提醒用户是否需要保存
- if(mModifyFlag=true)then
- begin
- //显示保存提示框
- if(MessageDlg('将改动保存到未命名?',
- mtConfirmation,[mbYes,mbNo],0) =mrYes) then
- //调用"保存"菜单的响应函数来保存文件
- MenuSaveClick(Sender);
- //设置修改状态
- mModifyFlag:=false;
- end;
- }
- end;
- //响应“图片”按钮的单击事件
- procedure TFormPaintbrush.ButtonPictureClick(Sender: TObject);
- begin
- //响应次数增1
- mCpno:=mCpno+1;
- //如果响应的次数为奇数
- if(mCpno mod 2=1) then
- begin
- //显示Panel1
- Panel1.Visible:=true;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- end
- //如果响应的次数为偶数,那么隐藏Panel1
- else Panel1.Visible:=false;
- end;
- //响应按扭“显示器”的单击事件
- procedure TFormPaintbrush.SpeedButtonDisplayClick(Sender: TObject);
- begin
- //设置当前选择的工具为11
- mType:=11;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应工具按扭“文字”的单击事件
- procedure TFormPaintbrush.ToolButtonCharClick(Sender: TObject);
- begin
- //清空Edit1的text
- FormTxt.Edit1.Clear;
- //设置当前选择的工具为12
- mType:=12;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=true;
- ToolButtonFont.Enabled:=true;
- //设置鼠标的形状
- FormCanvas.Cursor:=crIBeam;
- //设置初始字体的颜色
- FormTxt.Edit1.Font.Color:=shape1.Brush.Color;
- FormTxt.Edit1.Font.Name:='黑体';
- end;
- //响应工具按扭“字体”的单击事件
- procedure TFormPaintbrush.ToolButtonFontClick(Sender: TObject);
- begin
- //显示标准颜色对话框
- if FontDialog1.Execute() then
- begin
- //将Edit1的字体设置为字体对话框的字体
- FormTxt.Edit1.Font.Charset:=FontDialog1.Font.Charset;
- FormTxt.Edit1.Font.Color:=FontDialog1.Font.Color;
- FormTxt.Edit1.Font.Size:=FontDialog1.Font.Size;
- FormTxt.Edit1.Font.Name:=FontDialog1.Font.Name;
- FormTxt.Edit1.Font.Pitch:=FontDialog1.Font.Pitch;
- FormTxt.Edit1.Font.Height:=FontDialog1.Font.Height;
- FormTxt.Edit1.Font.Style:=FontDialog1.Font.Style;
- end;
- //将选择的颜色在颜色框和Shape1中显示出来
- ColorBox.Selected:=FontDialog1.Font.Color;
- Shape1.Brush.Color:=ColorBox.Selected;
- //设置绘图颜色
- mDrawColor:=Shape1.Brush.Color;
- //将文字输入窗口隐藏
- FormTxt.Hide;
- end;
- //响应按扭“路由器”的单击事件
- procedure TFormPaintbrush.SpeedButtonRouterClick(Sender: TObject);
- begin
- //设置当前选择的工具为13
- mType:=13;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应按扭“交换机”的单击事件
- procedure TFormPaintbrush.SpeedButtonSwitchClick(Sender: TObject);
- begin
- //设置当前选择的工具为14
- mType:=14;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应工具按扭“帮助”的单击事件
- procedure TFormPaintbrush.ToolButtonHelpClick(Sender: TObject);
- begin
- //显示关于屏幕画笔窗口
- FormAbout.Show;
- end;
- //响应按扭“调制解调器”的单击事件
- procedure TFormPaintbrush.SpeedButtonModemClick(Sender: TObject);
- begin
- //设置当前选择的工具为15
- mType:=15;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应按扭“光驱”的单击事件
- procedure TFormPaintbrush.SpeedButtonCDROMClick(Sender: TObject);
- begin
- //设置当前选择的工具为16
- mType:=16;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应按扭“服务器”的单击事件
- procedure TFormPaintbrush.SpeedButtonServerClick(Sender: TObject);
- begin
- //设置当前选择的工具为17
- mType:=17;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应按扭“数据库”的单击事件
- procedure TFormPaintbrush.SpeedButtonDBClick(Sender: TObject);
- begin
- //设置当前选择的工具为18
- mType:=18;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- //响应按扭“集线器”的单击事件
- procedure TFormPaintbrush.SpeedButtonConcentratorClick(Sender: TObject);
- begin
- //设置当前选择的工具为19
- mType:=19;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- procedure TFormPaintbrush.SpeedButton1Click(Sender: TObject);
- begin
- //设置当前选择的工具为20
- mType:=20;
- //工具条的down状态(即是否下压)
- ToolButtonLine.Down:=false;
- ToolButtonRectangle.Down:=false;
- ToolButtonEllipse.Down:=false;
- ToolButtonFEllipse.Down:=false;
- ToolButtonFRectangle.Down:=false;
- ToolButtonPen.Down:=false;
- ToolButtonEraser.Down:=false;
- ToolButtonArrow.Down:=false;
- ToolButtonOpen.Down:=false;
- ToolButtonSave.Down:=false;
- ToolButtonCut.Down:=false;
- ToolButtonEiminate.Down:=false;
- ToolButtonHelp.Down:=false;
- ToolButtonEC.Down:=false;
- ToolButtonChar.Down:=false;
- ToolButtonFont.Enabled:=false;
- //设置光标为十字光标
- FormCanvas.Cursor:=crArrow;
- end;
- procedure TFormPaintbrush.MenuMainHelpClick(Sender: TObject);
- begin
- //导入帮助文件
- Application.HelpFile:='D:屏幕画笔帮助.HLP';
- //显示帮助文件目录
- Application.HelpCommand(HELP_Index,0);
- end;
- end.