You've already forked lazarus-ccr
tvplanit: Add standard file dialog as property editor for datastore's DefaultEventSound
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4754 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -27,9 +27,7 @@
|
|||||||
{* ***** END LICENSE BLOCK ***** *}
|
{* ***** END LICENSE BLOCK ***** *}
|
||||||
|
|
||||||
{$I Vp.INC} { Compiler Version Defines }
|
{$I Vp.INC} { Compiler Version Defines }
|
||||||
//{$IFNDEF LCL}
|
|
||||||
{$R VpREG.RES} { Palette Glyphs }
|
{$R VpREG.RES} { Palette Glyphs }
|
||||||
//{$ENDIF}
|
|
||||||
|
|
||||||
unit VpReg;
|
unit VpReg;
|
||||||
{Registration unit for the Visual PlanIt design-time interface}
|
{Registration unit for the Visual PlanIt design-time interface}
|
||||||
@ -38,7 +36,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
{$IFDEF LCL}
|
{$IFDEF LCL}
|
||||||
LMessages,LCLProc,LCLType,LCLIntf,
|
LMessages, LCLProc, LCLType, LCLIntf,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Windows,
|
Windows,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -103,13 +101,21 @@ type
|
|||||||
TVpLocalizeFileNameProperty = class (TVpGenericFileNameProperty)
|
TVpLocalizeFileNameProperty = class (TVpGenericFileNameProperty)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TVpWavFileProperty = class(TStringProperty)
|
||||||
|
public
|
||||||
|
function GetAttributes: TPropertyAttributes; override;
|
||||||
|
function GetValue: string; override;
|
||||||
|
procedure Edit; override;
|
||||||
|
procedure SetValue(const Value: string); override;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
// DbTables, { VCL - BDE runtime unit }
|
// DbTables, { VCL - BDE runtime unit }
|
||||||
VpWavPE, { Wav File Finder - Property Editor }
|
// VpWavPE, { Wav File Finder - Property Editor }
|
||||||
|
|
||||||
{ Component Units }
|
{ Component Units }
|
||||||
VpBase, { Base classes for Vp }
|
VpBase, { Base classes for Vp }
|
||||||
@ -303,6 +309,53 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TVpWavFileProperty }
|
||||||
|
|
||||||
|
function TVpWavFileProperty.GetAttributes: TPropertyAttributes;
|
||||||
|
begin
|
||||||
|
Result := [paDialog];
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TVpWavFileProperty.GetValue: string;
|
||||||
|
begin
|
||||||
|
Result := GetStrValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TVpWavFileProperty.SetValue(const Value: string);
|
||||||
|
begin
|
||||||
|
SetStrValue(Value);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TVpWavFileProperty.Edit;
|
||||||
|
var
|
||||||
|
dlg: TOpenDialog;
|
||||||
|
ds: TVpCustomDatastore;
|
||||||
|
begin
|
||||||
|
ds := GetComponent(0) as TVpCustomDatastore;
|
||||||
|
if Assigned(ds) then
|
||||||
|
begin
|
||||||
|
dlg := TOpenDialog.Create(nil);
|
||||||
|
try
|
||||||
|
dlg.Filter := 'Wav files (*.wav)|*.wav|All files (*.*)|*.*';
|
||||||
|
dlg.FilterIndex := 1;
|
||||||
|
dlg.DefaultExt := '*.wav';
|
||||||
|
if ds.DefaultEventSound = '' then
|
||||||
|
dlg.InitialDir := ds.MediaFolder
|
||||||
|
else
|
||||||
|
dlg.InitialDir := ExtractFilePath(ds.DefaultEventSound);
|
||||||
|
if OD.Execute then
|
||||||
|
ds.DefaultEventSound := dlg.FileName;
|
||||||
|
finally
|
||||||
|
dlg.Free;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{*** component registration ***}
|
{*** component registration ***}
|
||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
@ -365,6 +418,9 @@ begin
|
|||||||
'DefaultEventSound', TWavFileProperty);
|
'DefaultEventSound', TWavFileProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RegisterPropertyEditor(TypeInfo(String), TVpCustomDatastore,
|
||||||
|
'DefaultEventSound', TVpWavFileProperty);
|
||||||
|
|
||||||
RegisterPropertyEditor (TypeInfo (TDateTime),
|
RegisterPropertyEditor (TypeInfo (TDateTime),
|
||||||
TVpPrintPreview,
|
TVpPrintPreview,
|
||||||
'StartDate',
|
'StartDate',
|
||||||
|
Reference in New Issue
Block a user