📄 d_lmddesignpanel.pas
字号:
unit d_LMDDesignPanel;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, LMDDsgDesigner,
LMDDsgClass, ExtCtrls, Buttons, Menus, Grids,
LMDDsgPropPage, LMDDsgPropInsp {$IFDEF VER130} ,LmdDsgD5Adds {$ENDIF}
, LMDDsgComboBox, LMDDsgManager;
type
// Class provides designer notification. Such capabilities already provided
// in the TCustomForm class, but if want to use not custom form descandant
// as DesignControl, then we must override Notification method as showed
// bellow. Otherwise OnNotification event of the TLMDDesigner will not work
// and DesignManager will not work will be incorrect.
TNotifyPanel = class(TPanel)
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
end;
// dummy class which is used as DesignControl
// demonstrates in DesignPanel how controls which are larger than
// client area are handled.
TTestPanel = class(TNotifyPanel)
public
constructor Create(AOwner: TComponent); override;
end;
TForm1 = class(TForm)
LMDDesignPanel1: TLMDDesignPanel;
Button1: TButton;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
d: TLMDDesigner;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
Label1: TLabel;
LMDPropertyInspector1: TLMDPropertyInspector;
LMDDesignManager1: TLMDDesignManager;
LMDObjectComboBox1: TLMDObjectComboBox;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure dComponentInserted(Sender: TObject);
procedure dComponentInserting(Sender: TObject;
var AComponentClass: TComponentClass);
private
{ Private declarations }
public
{ Public declarations }
Panel :TNotifyPanel;
TestPanel :TTestPanel;
end;
var
Form1: TForm1;
implementation
uses Math;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
d.Active:=False;
if Button1.Tag=0 then
begin
Button1.Tag:=1;
Button1.Caption:='Use simple Panel';
d.DesignControl:=TestPanel;
end
else
begin
Button1.Tag:=0;
Button1.Caption:='Use extended Panel (see code)';
d.DesignControl:=Panel;
Panel.Align:=alClient;
end;
d.Active:=True;
LMDDesignManager1.Designers[0].IsCurrent := True;
end;
constructor TTestPanel.Create(AOwner: TComponent);
begin
inherited Create(aOwner);
Width:=400;
Height:=500;
Color:=clWhite;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
RegisterStandardCategories(LMDPropertyInspector1);
Panel:=TNotifyPanel.Create(nil); // Owner=nil!!
Panel.Name := 'RootPanel';
TestPanel:=TTestPanel.Create(nil);
TestPanel.Name := 'RootExPanel';
Button1Click(nil);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
d.Active:=False;
if Button1.Tag=0 then
TestPanel.Free
else
Panel.Free;
end;
procedure TForm1.dComponentInserted(Sender: TObject);
begin
SpeedButton3.Down:=True;
end;
procedure TForm1.dComponentInserting(Sender: TObject;
var AComponentClass: TComponentClass);
begin
if SpeedButton1.Down then
AComponentClass:=TLabel
else if SpeedButton2.Down then
AComponentClass:=TButton
else if SpeedButton4.Down then
AComponentClass:=TMemo
else if SpeedButton5.Down then
AComponentClass:=TCheckBox;
end;
{ TExPanel }
procedure TNotifyPanel.Notification(AComponent: TComponent;
Operation: TOperation);
var
LForm: TCustomForm;
begin
inherited;
// Notify parent form designer (if any)
LForm := GetParentForm(Self);
if (LForm <> nil) and (LForm.Designer <> nil) then
LForm.Designer.Notification(AComponent, Operation);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -