📄 jvdyncontrolenginejvcldb.pas
字号:
{$ENDIF HAS_UNIT_VARIANTS}
SysUtils,
JvDynControlEngineVCLDB,
JvDynControlEngineTools, JvDynControlEngineJVCL, JvConsts, JvJCLUtils;
var
IntDynControlEngineJVCLDB: TJvDynControlEngineDB = nil;
//=== { TJvDynControlJVCLDBEdit } ============================================
procedure TJvDynControlJVCLDBEdit.ControlSetDefaultProperties;
begin
end;
procedure TJvDynControlJVCLDBEdit.ControlSetReadOnly(Value: Boolean);
begin
ReadOnly := Value;
end;
procedure TJvDynControlJVCLDBEdit.ControlSetCaption(const Value: string);
begin
end;
procedure TJvDynControlJVCLDBEdit.ControlSetTabOrder(Value: Integer);
begin
TabOrder := Value;
end;
procedure TJvDynControlJVCLDBEdit.ControlSetHint(const Value: string);
begin
Hint := Value;
end;
procedure TJvDynControlJVCLDBEdit.ControlSetOnEnter(Value: TNotifyEvent);
begin
OnEnter := Value;
end;
procedure TJvDynControlJVCLDBEdit.ControlSetOnExit(Value: TNotifyEvent);
begin
OnExit := Value;
end;
procedure TJvDynControlJVCLDBEdit.ControlSetOnChange(Value: TNotifyEvent);
begin
OnChange := Value;
end;
procedure TJvDynControlJVCLDBEdit.ControlSetOnClick(Value: TNotifyEvent);
begin
end;
procedure TJvDynControlJVCLDBEdit.ControlSetValue(Value: Variant);
begin
Text := Value;
end;
function TJvDynControlJVCLDBEdit.ControlGetValue: Variant;
begin
Result := Text;
end;
procedure TJvDynControlJVCLDBEdit.ControlSetPasswordChar(Value: Char);
begin
{$IFDEF VCL}
PasswordChar := Value;
{$ENDIF VCL}
{$IFDEF VisualCLX}
if Value = #0 then
EchoMode := emNormal
else
EchoMode := emPassword;
{$ENDIF VisualCLX}
end;
procedure TJvDynControlJVCLDBEdit.ControlSetEditMask(const Value: string);
begin
//EditMask := Value;
end;
procedure TJvDynControlJVCLDBEdit.ControlSetDataSource(Value: TDataSource);
begin
DataSource := Value;
end;
function TJvDynControlJVCLDBEdit.ControlGetDataSource: TDataSource;
begin
Result := DataSource;
end;
procedure TJvDynControlJVCLDBEdit.ControlSetDataField(const Value: string);
begin
DataField := Value;
end;
function TJvDynControlJVCLDBEdit.ControlGetDataField: string;
begin
Result := DataField;
end;
//=== { TJvDynControlJVCLDBButtonEdit } ======================================
constructor TJvDynControlJVCLDBButtonEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FEditControl := TJvDBMaskEdit.Create(AOwner);
FEditControl.Parent := Self;
FButton := TBitBtn.Create(AOwner);
FButton.Parent := Self;
FButton.Align := alRight;
FButton.Caption := '...';
Height := FEditControl.Height;
FButton.Width := Height;
FEditControl.Align := alClient;
BevelInner := bvNone;
BevelOuter := bvNone;
end;
destructor TJvDynControlJVCLDBButtonEdit.Destroy;
begin
FreeAndNil(FEditControl);
FreeAndNil(FButton);
inherited Destroy;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetDefaultProperties;
begin
Self.Caption := ' ';
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetReadOnly(Value: Boolean);
begin
FEditControl.ReadOnly := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetCaption(const Value: string);
begin
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetTabOrder(Value: Integer);
begin
TabOrder := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetHint(const Value: string);
begin
Hint := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetOnEnter(Value: TNotifyEvent);
begin
OnEnter := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetOnExit(Value: TNotifyEvent);
begin
OnExit := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetOnChange(Value: TNotifyEvent);
begin
FEditControl.OnChange := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetOnClick(Value: TNotifyEvent);
begin
FEditControl.OnClick := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetValue(Value: Variant);
begin
FEditControl.Text := Value;
end;
function TJvDynControlJVCLDBButtonEdit.ControlGetValue: Variant;
begin
Result := FEditControl.Text;
end;
{$IFDEF VisualCLX}
type
TJvDBMaskEditAccessProtected = class(TJvDBMaskEdit);
{$ENDIF VisualCLX}
procedure TJvDynControlJVCLDBButtonEdit.ControlSetPasswordChar(Value: Char);
begin
{$IFDEF VCL}
FEditControl.PasswordChar := Value;
{$ENDIF VCL}
{$IFDEF VisualCLX}
if Value = #0 then
TJvDBMaskEditAccessProtected(FEditControl).EchoMode := emNormal
else
TJvDBMaskEditAccessProtected(FEditControl).EchoMode := emPassword;
{$ENDIF VisualCLX}
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetEditMask(const Value: string);
begin
//FEditControl.EditMask := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetOnButtonClick(Value: TNotifyEvent);
begin
FButton.OnClick := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetButtonCaption(const Value: string);
begin
FButton.Caption := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetGlyph(Value: TBitmap);
begin
FButton.Glyph.Assign(Value);
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetNumGlyphs(Value: Integer);
begin
FButton.NumGlyphs := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetLayout(Value: TButtonLayout);
begin
FButton.Layout := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetDefault(Value: Boolean);
begin
FButton.Default := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetCancel(Value: Boolean);
begin
FButton.Cancel := Value;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetDataSource(Value: TDataSource);
begin
FEditControl.DataSource := Value;
end;
function TJvDynControlJVCLDBButtonEdit.ControlGetDataSource: TDataSource;
begin
Result := FEditControl.DataSource;
end;
procedure TJvDynControlJVCLDBButtonEdit.ControlSetDataField(const Value: string);
begin
FEditControl.DataField := Value;
end;
function TJvDynControlJVCLDBButtonEdit.ControlGetDataField: string;
begin
Result := FEditControl.DataField;
end;
//=== { TJvDynControlJVCLDBFileNameEdit } ====================================
constructor TJvDynControlJVCLDBFileNameEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FEditControl := TJvDBMaskEdit.Create(AOwner);
FEditControl.Parent := Self;
FButton := TBitBtn.Create(AOwner);
FButton.Parent := Self;
FButton.Align := alRight;
FButton.OnClick := DefaultOnButtonClick;
FButton.Caption := '...';
Height := FEditControl.Height;
FButton.Width := Height;
FEditControl.Align := alClient;
FDialogOptions := [ofHideReadOnly,ofEnableSizing];
BevelInner := bvNone;
BevelOuter := bvNone;
FDialogKind := jdkOpen;
end;
destructor TJvDynControlJVCLDBFileNameEdit.Destroy;
begin
FreeAndNil(FEditControl);
FreeAndNil(FButton);
inherited Destroy;
end;
procedure TJvDynControlJVCLDBFileNameEdit.DefaultOnButtonClick(Sender: TObject);
begin
case FDialogKind of
jdkOpen:
with TOpenDialog.Create(Self) do
try
Options := FDialogOptions;
Title := FDialogTitle;
Filter := FFilter;
FilterIndex := FFilterIndex;
InitialDir := FInitialDir;
DefaultExt := FDefaultExt;
FileName := ControlGetValue;
if Execute then
ControlSetValue(FileName);
finally
Free;
end;
jdkOpenPicture:
with TOpenPictureDialog.Create(Self) do
try
Options := FDialogOptions;
Title := FDialogTitle;
Filter := FFilter;
FilterIndex := FFilterIndex;
InitialDir := FInitialDir;
DefaultExt := FDefaultExt;
FileName := ControlGetValue;
if Execute then
ControlSetValue(FileName);
finally
Free;
end;
jdkSave:
with TSaveDialog.Create(Self) do
try
Options := FDialogOptions;
Title := FDialogTitle;
Filter := FFilter;
FilterIndex := FFilterIndex;
InitialDir := FInitialDir;
DefaultExt := FDefaultExt;
FileName := ControlGetValue;
if Execute then
ControlSetValue(FileName);
finally
Free;
end;
jdkSavePicture:
with TSavePictureDialog.Create(Self) do
try
Options := FDialogOptions;
Title := FDialogTitle;
Filter := FFilter;
FilterIndex := FFilterIndex;
InitialDir := FInitialDir;
DefaultExt := FDefaultExt;
FileName := ControlGetValue;
if Execute then
ControlSetValue(FileName);
finally
Free;
end;
end;
if FEditControl.CanFocus then
FEditControl.SetFocus;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetDefaultProperties;
begin
Caption := ' ';
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetReadOnly(Value: Boolean);
begin
FEditControl.ReadOnly := Value;
FButton.Enabled := not Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetCaption(const Value: string);
begin
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetTabOrder(Value: Integer);
begin
TabOrder := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetHint(const Value: string);
begin
Hint := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetOnEnter(Value: TNotifyEvent);
begin
FEditControl.OnEnter := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetOnExit(Value: TNotifyEvent);
begin
FEditControl.OnExit := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetOnChange(Value: TNotifyEvent);
begin
FEditControl.OnChange := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetOnClick(Value: TNotifyEvent);
begin
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetValue(Value: Variant);
begin
FEditControl.Text := Value;
end;
function TJvDynControlJVCLDBFileNameEdit.ControlGetValue: Variant;
begin
Result := FEditControl.Text;
end;
// IJvDynControlFileName
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetInitialDir(const Value: string);
begin
FInitialDir := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetDefaultExt(const Value: string);
begin
FDefaultExt := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetDialogTitle(const Value: string);
begin
FDialogTitle := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetDialogOptions(Value: TOpenOptions);
begin
FDialogOptions := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetFilter(const Value: string);
begin
FFilter := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetFilterIndex(Value: Integer);
begin
FFilterIndex := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetDialogKind(Value: TJvDynControlFileNameDialogKind);
begin
FDialogKind := Value;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetDataSource(Value: TDataSource);
begin
FEditControl.DataSource := Value;
end;
function TJvDynControlJVCLDBFileNameEdit.ControlGetDataSource: TDataSource;
begin
Result := FEditControl.DataSource;
end;
procedure TJvDynControlJVCLDBFileNameEdit.ControlSetDataField(const Value: string);
begin
FEditControl.DataField := Value;
end;
function TJvDynControlJVCLDBFileNameEdit.ControlGetDataField: string;
begin
Result := FEditControl.DataField;
end;
//=== { TJvDynControlJVCLDBDirectoryEdit } ===================================
constructor TJvDynControlJVCLDBDirectoryEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FEditControl := TJvDBMaskEdit.Create(AOwner);
FEditControl.Parent := Self;
FButton := TBitBtn.Create(AOwner);
FButton.Parent := Self;
FButton.Align := alRight;
FButton.OnClick := DefaultOnButtonClick;
FButton.Caption := '...';
Height := FEditControl.Height;
FButton.Width := Height;
FEditControl.Align := alClient;
BevelInner := bvNone;
BevelOuter := bvNone;
end;
destructor TJvDynControlJVCLDBDirectoryEdit.Destroy;
begin
FreeAndNil(FEditControl);
FreeAndNil(FButton);
inherited Destroy;
end;
procedure TJvDynControlJVCLDBDirectoryEdit.DefaultOnButtonClick(Sender: TObject);
var
{$IFDEF VCL}
Opt: TSelectDirOpts;
Dir: string;
{$ENDIF VCL}
{$IFDEF VisualCLX}
Dir: WideString;
{$ENDIF VisualCLX}
begin
Dir := ControlGetValue;
if Dir = '' then
if FInitialDir <> '' then
Dir := FInitialDir
else
Dir := PathDelim;
if not DirectoryExists(Dir) then
Dir := PathDelim;
{$IFDEF VCL}
if SelectDirectory(Dir, Opt, HelpContext) then
{$ENDIF VCL}
{$IFDEF VisualCLX}
{$IFDEF MSWINDOWS}
if SelectDirectory('', '', Dir) then
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
if SelectDirectory('', '/', Dir, False) then
{$ENDIF UNIX}
{$ENDIF VisualCLX}
ControlSetValue(Dir);
if FEditControl.CanFocus then
FEditControl.SetFocus;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -