Chapter 11 - Package MdDesPk |
Package Structure
| MdArrReg.pas |
unit MdArrReg;
interface
uses
DesignIntf, Classes;
procedure Register;
implementation
uses
MdArrow;
procedure Register;
begin
RegisterComponents ('Md', [TMdArrow]);
RegisterPropertyInCategory (
'Input', TMdArrow, 'OnArrowDblClick');
RegisterPropertyInCategory (
'Arrow', TMdArrow, 'Direction');
RegisterPropertyInCategory (
'Arrow', TMdArrow, 'ArrowHeight');
RegisterPropertyInCategory (
'Arrow', TMdArrow, 'Filled');
RegisterPropertyInCategory (
'Visual', TMdArrow, 'Filled');
end;
end.
| MdCompEdit.pas |
unit MdCompEdit;
interface
uses
DesignIntf, DesignEditors;
type
TMdListCompEditor = class (TComponentEditor)
function GetVerbCount: Integer; override;
function GetVerb(Index: Integer): string; override;
procedure ExecuteVerb(Index: Integer); override;
procedure Edit; override;
end;
procedure Register;
implementation
uses
SysUtils, Dialogs, StdCtrls, MdListDial;
function TMdListCompEditor.GetVerbCount: Integer;
begin
Result := 3;
end;
function TMdListCompEditor.GetVerb (Index: Integer): string;
begin
case Index of
0: Result := 'MdListDialog (�Cant�)';
1: Result := '&About this component...';
2: Result := '&Preview...';
end;
end;
procedure TMdListCompEditor.ExecuteVerb (Index: Integer);
begin
case Index of
0..1: MessageDlg (
'This is a simple component editor'#13 +
'built by Marco Cant�'#13 +
'for the book "Mastering Delphi"',
mtInformation, [mbOK], 0);
2: with Component as TMdListDialog do
Execute;
end;
end;
procedure TMdListCompEditor.Edit;
begin
Beep;
ExecuteVerb (0);
end;
procedure Register;
begin
RegisterComponentEditor (
TMdListDialog, TMdListCompEditor);
end;
end.
| PeFSound.pas |
unit PeFSound;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, StdCtrls;
type
TSoundForm = class(TForm)
Label1: TLabel;
btnOK: TBitBtn;
btnCancel: TBitBtn;
btnLoad: TSpeedButton;
OpenDialog1: TOpenDialog;
btnPlay: TBitBtn;
ComboBox1: TComboBox;
procedure btnLoadClick(Sender: TObject);
procedure btnPlayClick(Sender: TObject);
private
public
end;
var
SoundForm: TSoundForm;
implementation
uses
MMSystem;
procedure TSoundForm.btnLoadClick(Sender: TObject);
begin
if OpenDialog1.Execute then
ComboBox1.Text := OpenDialog1.FileName;
end;
procedure TSoundForm.btnPlayClick(Sender: TObject);
begin
PlaySound (PChar (ComboBox1.Text), 0, snd_Async);
end;
end.
| PeSound.pas |
unit PeSound;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DesignIntf, DesignEditors;
type
TSoundProperty = class (TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
procedure Edit; override;
end;
procedure Register;
implementation
uses
MdSounB,
PeFSound;
function TSoundProperty.GetAttributes:
TPropertyAttributes;
begin
Result := [paDialog, paMultiSelect, paValueList, paSortList];
end;
procedure TSoundProperty.GetValues(Proc: TGetStrProc);
begin
Proc ('Maximize');
Proc ('Minimize');
Proc ('MenuCommand');
Proc ('MenuPopup');
Proc ('RestoreDown');
Proc ('RestoreUp');
Proc ('SystemAsterisk');
Proc ('SystemDefault');
Proc ('SystemExclamation');
Proc ('SystemExit');
Proc ('SystemHand');
Proc ('SystemQuestion');
Proc ('SystemStart');
Proc ('AppGPFault');
end;
procedure TSoundProperty.Edit;
begin
SoundForm := TSoundForm.Create (Application);
try
SoundForm.ComboBox1.Text := GetValue;
if SoundForm.ShowModal = mrOK then
SetValue (SoundForm.ComboBox1.Text);
finally
SoundForm.Free;
end;
end;
procedure Register;
begin
RegisterPropertyEditor (TypeInfo(string),
TMdSoundButton, 'SoundUp', TSoundProperty);
RegisterPropertyEditor (TypeInfo(string),
TMdSoundButton, 'SoundDown', TSoundProperty);
end;
end.
|
|