国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Delphi > 正文

Delphi圖象截取編程示例(3)

2019-11-18 18:12:11
字體:
來源:轉載
供稿:網友
 

(五)TMainForm的事件和函數 和 TPRinter打印應用
////////// 打印知識
[菜單項file/打印] 事件:
procedure TMainForm.filePrintItemClick(Sender: TObject);
begin
  {kh1}print;{kh2}
  Screen.Cursor := crHourglass;
  try
    if MDIChildCount<>0 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;

[菜單項file/打印設置] 事件:
procedure TMainForm.filePrintSetClick(Sender: TObject);
begin
  Screen.Cursor:=crHourglass;
  PrinterSetupDialog1.Execute ;
  Screen.Cursor:=crDefault;
end;
   
[菜單項edit/Preferences/ToolBar] 事件:
procedure TMainForm.toolbarItemClick(Sender: TObject);
begin
  toolbarItem.Checked := not toolbarItem.Checked ;
  ToolBar2.Visible := toolbarItem.Checked;
end; 
   
[MainMenu1.OnChange] 事件
procedure TMainForm.MainMenu1Change(...);
begin
  filePrintItem.Enabled := MDIChildCount>0;
  DrawItem.Enabled := MDIChildCount>0;
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;

[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;


上一篇:Delphi圖象截取編程示例(4)

下一篇:Delphi圖象截取編程示例(2)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 彭山县| 太谷县| 焦作市| 沙雅县| 襄樊市| 忻城县| 皋兰县| 镶黄旗| 柳河县| 无极县| 丹寨县| 教育| 安乡县| 资阳市| 徐州市| 邛崃市| 会昌县| 财经| 福鼎市| 龙川县| 怀远县| 铁力市| 集安市| 环江| 台江县| 平果县| 新干县| 巴塘县| 建平县| 久治县| 卢氏县| 长阳| 乳山市| 梁平县| 新和县| 隆尧县| 天柱县| 苍南县| 台东市| 遂平县| 陇南市|