📄 pictures.pas
字号:
unit Pictures;
interface
uses
{$IFDEF LINUX}
SysUtils, Types, Classes, QGraphics, QControls, QForms, QDialogs, QStdCtrls,
QDBCtrls, QComCtrls, QExtCtrls, QGrids, QDBGrids, QButtons, OdacClx,
{$ELSE}
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DBCtrls, ExtCtrls, Grids, DBGrids, StdCtrls, ToolWin, ComCtrls, ExtDlgs,
Buttons, OdacVcl,
{$ENDIF}
Db, MemDS, DBAccess, Ora, OraSmart, OdacDemoFrame, OdacDemoForm;
type
TPicturesFrame = class(TOdacDemoFrame)
DBGrid: TDBGrid;
ToolBar: TPanel;
ToolBar1: TPanel;
Splitter1: TSplitter;
ScrollBox1: TScrollBox;
DBImage: TDBImage;
dsPictures: TDataSource;
quPictures: TSmartQuery;
Panel1: TPanel;
btLoad: TSpeedButton;
btSave: TSpeedButton;
btClear: TSpeedButton;
Panel2: TPanel;
btOpen: TSpeedButton;
btClose: TSpeedButton;
DBNavigator: TDBNavigator;
procedure btOpenClick(Sender: TObject);
procedure btCloseClick(Sender: TObject);
procedure btLoadClick(Sender: TObject);
procedure btSaveClick(Sender: TObject);
procedure btClearClick(Sender: TObject);
private
{ Private declarations }
public
procedure Initialize; override;
procedure SetDebug(Value: boolean); override;
end;
implementation
uses
OraCall;
{$IFDEF CLR}
{$R *.nfm}
{$ENDIF}
{$IFDEF WIN32}
{$R *.dfm}
{$ENDIF}
{$IFDEF LINUX}
{$R *.xfm}
{$ENDIF}
procedure TPicturesFrame.Initialize;
begin
inherited;
quPictures.Connection := Connection;
end;
procedure TPicturesFrame.btOpenClick(Sender: TObject);
begin
quPictures.Open;
end;
procedure TPicturesFrame.btCloseClick(Sender: TObject);
begin
quPictures.Close;
end;
procedure TPicturesFrame.btLoadClick(Sender: TObject);
begin
{$IFDEF LINUX}
with TOpenDialog.Create(nil) do
{$ELSE}
with TOpenPictureDialog.Create(nil) do
{$ENDIF}
try
InitialDir := ExtractFilePath(Application.ExeName) + 'Pictures';
if Execute then begin
if quPictures.State in [dsBrowse] then
quPictures.Edit;
TBlobField(quPictures.FieldByName('Picture')).
LoadFromFile(FileName);
end;
finally
Free;
end;
end;
procedure TPicturesFrame.btSaveClick(Sender: TObject);
begin
{$IFDEF LINUX}
with TSaveDialog.Create(nil) do
{$ELSE}
with TSavePictureDialog.Create(nil) do
{$ENDIF}
try
InitialDir := ExtractFilePath(Application.ExeName) + 'Pictures';
if Execute then begin
TBlobField(quPictures.FieldByName('Picture')).
SaveToFile(FileName);
end;
finally
Free;
end;
end;
procedure TPicturesFrame.btClearClick(Sender: TObject);
begin
if quPictures.State in [dsBrowse] then
quPictures.Edit;
TBlobField(quPictures.FieldByName('Picture')).Clear;
end;
procedure TPicturesFrame.SetDebug(Value: boolean);
begin
quPictures.Debug := Value;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -