Delphi图象截取编程示例(3)

2016-02-19 14:20 2 1 收藏

每个人都希望每天都是开心的,不要因为一些琐事扰乱了心情还,闲暇的时间怎么打发,关注图老师可以让你学习更多的好东西,下面为大家推荐Delphi图象截取编程示例(3),赶紧看过来吧!

【 tulaoshi.com - 编程语言 】

 

  (五)TMainForm的事件和函数 和 TPrinter打印应用
  ////////// 打印知识
  [菜单项file打印] 事件:
  procedure TMainForm.filePrintItemClick(Sender: TObject);
  begin
    {kh1}print;{kh2}
    Screen.Cursor := crHourglass;
    try
      if MDIChildCount0 then
        with ActiveMDIChild as TMDIChild do begin
          with Printer do begin
            BeginDoc;                                  //开始打印
            Canvas.Draw(0,0,Image1.Picture.Graphic);   //图形输出
            EndDoc;                                    //结束打印
          end;
        end;
    finally
      Screen.Cursor := crDefault;
    end;
  end;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  [菜单项file打印设置] 事件:
  procedure TMainForm.filePrintSetClick(Sender: TObject);
  begin
    Screen.Cursor:=crHourglass;
    PrinterSetupDialog1.Execute ;
    Screen.Cursor:=crDefault;
  end;
     
  [菜单项editPreferencesToolBar] 事件:
  
procedure TMainForm.toolbarItemClick(Sender: TObject);
  begin
    toolbarItem.Checked := not toolbarItem.Checked ;
    ToolBar2.Visible := toolbarItem.Checked;
  end; 
     
  [MainMenu1.OnChange] 事件
  
procedure TMainForm.MainMenu1Change(...);
  begin
    filePrintItem.Enabled := MDIChildCount0;
    DrawItem.Enabled := MDIChildCount0;
  end;

  [TMainForm.FormCreate] 事件
  procedure TMainForm.FormCreate(Sender: TObject);
  begin
    CaptureNum:=0;
    DefaultDirectory:=ExtractFilePath(Application.ExeName);
  end;
     
  [TMainForm.FileOpen] 事件
  
procedure TMainForm.OpenDialogExecute(Sender: TObject);
  begin
    OpenDialog.InitialDir := DefaultDirectory;
    if OpenDialog.Execute then
    begin
      DefaultDirectory:=ExtractFileName(OpenDialog.FileName);
      CreateMDIChild(OpenDialog.FileName,false);
    end;;
  end;

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/bianchengyuyan/)

  [TMainForm.FileSave、TMainForm.FileSaveAs] 事件
  procedure TMainForm.FileSave1Execute(Sender: TObject);
  begin
    with ActiveMDIChild as TMDIChild do begin
      FileName:=ExtractFileName(caption);
      FileName:=DefaultDirectory+FileName;
      SaveDialog.FileName:=FileName;
      if not SaveDialog.Execute then exit;
      FileName:=SaveDialog.FileName ;
      DefaultDirectory:=ExtractFileName(FileName);
      if FileExists(FileName)then begin
        if MessageDlg(FileName+' 已存在,替换它吗?',mtInformation,[mbYES,mbNO],0)=mrYES then
          DeleteFile(FileName)
        else exit;
      end;
      Image1.Picture.saveToFile(FileName);
      Caption:=FileName;
      StatusBar.SimpleText := FileName;
    end;
  end;

来源:https://www.tulaoshi.com/n/20160219/1606762.html

延伸阅读
标签: Delphi
  拖放 (DragDrop)是 Windows 提供的一种快捷的操作方式。作为基于 Windows 的开发工具, Delphi同样支持拖放操作,而且开发应用系统的拖放功能十分方便,真正体现了 Delphi 的强大功能和方便性。 Delphi提供的所有控件 (Control ,即能获得输入焦点的部件 ) 都支持拖放操作,并有相应的拖放属性、拖放事件和拖放方法。下面我...
◇[DELPHI]网络邻居复制文件 uses shellapi; copyfile(pchar('newfile.txt'),pchar('//computername/direction/targer.txt'),false); ◇[DELPHI]产生鼠标拖动效果 通过MouseMove事件、DragOver事件、EndDrag事件实现,例如在PANEL上的LABEL: var xpanel,ypanel,xlabel,ylabel:integer; PAN...
标签: Delphi
  Delphi作为一门新起的Windows编程语言,由于其集众多的优秀特性于一身,因而越来越得到广大编程人员和发烧友的青睐。以下十则技巧涉及的面比较广泛,希望能够对Delphi的爱好者有所裨益。 1.类似于vb.中的doevents功能。 大家或许发现,在Delphi中没有类似于vb.中的doevents函数,这样有的时候,我们将无法使Windows响应...
Delphi3开始有了TWebBrowser构件,不过那时是以ActiveX控件的形式出现的,而且需要自己引入,在其后的4.0和5.0中,它就在封装好shdocvw.dll之后作为Internet构件组之一出现在构件面板上了。常常听到有人骂Delphi的帮助做得极差,这次的TWebBrowser又是Microsoft的东东,自然不会好到哪里去,虽说MSDN上什么都有,可是内容太过庞杂,如果没有入口...
标签: Delphi
在Delphi中涉及到系统编程的方面毫无例外都要调用API函数,在ShellAPI.pas单元中有要用到的API函数的原型。 实战演练: 一.新建一个应用程序:File->New Applicaton 在Interface部分定义一个消息常量:const WM_NID=WM_USER+1000; 系统规定从WM_USER开始为用户自定义消息。 二.定义一个全局变量: NotifyIcon:TNotifyIc...

经验教程

105

收藏

19
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部