每个人都希望每天都是开心的,不要因为一些琐事扰乱了心情还,闲暇的时间怎么打发,关注图老师可以让你学习更多的好东西,下面为大家推荐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;
[菜单项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;
[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;
来源:http://www.tulaoshi.com/n/20160219/1606762.html
看过《Delphi图象截取编程示例(3)》的人还看了以下文章 更多>>