📄 pic.pas
字号:
unit pic;
interface
uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
Buttons, ExtCtrls, ExtDlgs, Dialogs,printers,jpeg,prints;
type
TOKBottomDlg5 = class(TForm)
Bevel1: TBevel;
Image1: TImage;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
Label3: TLabel;
Edit2: TEdit;
OpenPictureDialog1: TOpenPictureDialog;
Image2: TImage;
Label8: TLabel;
SpeedButton4: TSpeedButton;
PrinterSetupDialog1: TPrinterSetupDialog;
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
printstauts:integer;//打屯机状态
attri:integer;
procedure threadpdone(sender:tobject);
public
{ Public declarations }
threadp:tprintthread;
end;
var
OKBottomDlg5: TOKBottomDlg5;
implementation
uses cgmain;
{$R *.dfm}
procedure TOKBottomDlg5.SpeedButton3Click(Sender: TObject);
begin
OKBottomDlg5.Close;
end;
procedure TOKBottomDlg5.SpeedButton1Click(Sender: TObject);
begin
if OKBottomDlg5.OpenPictureDialog1.Execute then
begin
image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
// image2.Picture.LoadFromFile(OpenPictureDialog1.FileName);
end;
end;
procedure TOKBottomDlg5.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
try
image1.Picture.LoadFromFile(extractfilepath(paramstr(0))+'\picture\'+trim(edit2.Text)+'.jpg');
// image2.Picture.LoadFromFile(extractfilepath(paramstr(0))+'\picture\'+trim(edit2.Text)+'.jpg');
Attri:=FileGetAttr(extractfilepath(paramstr(0))+'\picture\'+trim(edit2.Text)+'.jpg');
if (Attri and faReadOnly) = faReadOnly then
FileSetAttr(extractfilepath(paramstr(0))+'\picture\'+trim(edit2.Text)+'.jpg',32);
except
image1.Picture.Graphic:=nil;
// image2.Picture.Graphic:=nil;
application.MessageBox('没找到图片!','提示',mb_ok);
end;
end;
end;
procedure TOKBottomDlg5.SpeedButton2Click(Sender: TObject);
var
bmptmp:Tbitmap;
jt:Tjpegimage;
begin
if (image1.Picture.Graphic=nil) then
begin
application.MessageBox('图片为空,不能保存图片!','提示',mb_ok);
edit2.Clear;
exit;
end;
if (trim(edit2.Text)='') then
begin
application.MessageBox('陈述通知单号码为空,不能保存图片)!','提示',mb_ok);
edit2.setfocus;
exit;
end;
if (application.MessageBox(pchar('以陈述通知单号码['+edit2.text + ']为图片文件名,是否保存!'),'提示',mb_yesno)=IDNO) then exit;
if fileexists(extractfilepath(paramstr(0))+'\picture\'+trim(edit2.Text)+'.jpg') then
if application.MessageBox('此文件已存在,是否覆盖此文件!','提示',mb_yesno)=7 then exit;
// try
try
form1.tempquery.Close;
form1.tempquery.SQL.Clear;
form1.tempquery.SQL.Add('update wf_zl_info set tpdz='''+extractfilepath(paramstr(0))+'picture\'+trim(edit2.Text)+'.jpg'+''''+' where tzshm='''
+trim(edit2.Text)+'''');
form1.tempquery.ExecSQL;
form1.tempquery.Close;
except
application.MessageBox('保存图片不成功,可能是陈述通知书号码不存在!','提示',mb_ok);
// bmptmp.Free;
// jt.free;
edit2.Clear;
edit2.setfocus;
exit;
end;
try
bmptmp:=Tbitmap.Create();
jt:=Tjpegimage.Create();
bmptmp.Assign(image1.Picture.Graphic);
bmptmp.Canvas.Font.Color:=clred;
bmptmp.Canvas.Font.Name:='宋体';
bmptmp.Canvas.Font.Size:=24;
bmptmp.Canvas.TextOut(5,5,'陈述通知书号:'+trim(edit2.Text));
image1.Picture.Graphic.Assign(bmptmp);
jt.Assign(bmptmp);
jt.SaveToFile(extractfilepath(paramstr(0))+'\picture\'+trim(edit2.Text)+'.jpg');
//image1.Picture.c.SaveToFile(extractfilepath(paramstr(0))+'\picture\'+trim(edit2.Text)+'.jpg');
except
application.MessageBox('保存图片不成功,可能是文件错误!','提示',mb_ok);
bmptmp.Free;
jt.free;
edit2.Clear;
edit2.setfocus;
exit;
end; bmptmp.Free;
jt.free;
edit2.Clear;
edit2.setfocus;
end;
procedure TOKBottomDlg5.SpeedButton4Click(Sender: TObject);
begin
if printstauts=1 then begin application.MessageBox('图片打印进程正在进行!请稍后','提示',mb_ok);exit;end;
if (image1.Picture.Graphic=nil) then begin application.MessageBox('图片元素为空!','提示',mb_ok);exit;end;
if application.MessageBox('是否进行图片打印!','提示',mb_yesno)=6 then
if okbottomdlg5.PrinterSetupDialog1.Execute= true then
begin
printstauts:=1;
showmessage('打印正在进行工作,2分钟后完成!');
threadp:=tprintthread.create();
threadp.Priority:=tplowest;
threadp.OnTerminate:=threadpdone;
end;
end;
procedure TOKBottomDlg5.threadpdone(sender:tobject);
begin
printstauts:=0;
end;
procedure TOKBottomDlg5.FormShow(Sender: TObject);
begin
printstauts:=0;
end;
procedure TOKBottomDlg5.FormCreate(Sender: TObject);
begin
OpenPictureDialog1.InitialDir := extractfilepath(paramstr(0))+'\picture\'
end;
procedure TOKBottomDlg5.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
form1.tempquery.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -