📄 dialogresourceform.pas
字号:
(*======================================================================*
| DialogResourceForm |
| |
| Version Date By Description |
| ------- ---------- ---- ------------------------------------------|
| 1.0 14/03/2001 CPWW Original |
*======================================================================*)
unit DialogResourceForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, menus,
ResourceForm, ImgList, ComCtrls, ToolWin, cmpSizingPageControl,
cmpDialogBox, cmpRuler, cmpPropertyListBox, cmpDialogEditor, StdCtrls, ExtCtrls,
unitResourceDialogs;
type
TfmDialogResource = class(TfmResource)
pnlProperties: TPanel;
Splitter1: TSplitter;
ScrollBox1: TScrollBox;
pnlPropertyCombo: TPanel;
cbControls: TComboBox;
Panel3: TPanel;
Panel4: TPanel;
DialogEditor1: TDialogEditor;
Ruler1: TRuler;
Ruler2: TRuler;
tcPropertyKind: TTabControl;
PropertyListBox1: TPropertyListBox;
SizingPageControl1: TSizingPageControl;
pnlPalette: TPanel;
ImageList1: TImageList;
Panel1: TPanel;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
ToolButton8: TToolButton;
ToolButton9: TToolButton;
ToolButton10: TToolButton;
ToolButton11: TToolButton;
ToolButton12: TToolButton;
ToolButton13: TToolButton;
ToolButton14: TToolButton;
ToolButton15: TToolButton;
ToolButton16: TToolButton;
ToolButton17: TToolButton;
ToolButton18: TToolButton;
ToolButton19: TToolButton;
ToolButton20: TToolButton;
ToolButton21: TToolButton;
ToolButton22: TToolButton;
ToolButton23: TToolButton;
ToolButton24: TToolButton;
ToolButton25: TToolButton;
ToolButton26: TToolButton;
FontDialog1: TFontDialog;
procedure DialogEditor1Resize(Sender: TObject);
procedure DialogEditor1DesignModeSelectedItemChange(Sender: TObject);
procedure DialogEditor1Show(Sender: TObject);
procedure cbControlsChange(Sender: TObject);
procedure PropertyListBox1PropertyChanged(Sender: TObject);
procedure tcPropertyKindChange(Sender: TObject);
procedure DialogEditor1ControlResize(Sender: TObject;
ctrlInfo: TControlInfo; newRect: TRect);
procedure DialogEditor1ControlPropertyChange(Sender: TObject;
ctrlInfo: TControlInfo);
procedure FormShow(Sender: TObject);
procedure SizingPageControl1UnDock(Sender: TObject; Client: TControl;
NewTarget: TWinControl; var Allow: Boolean);
procedure SizingPageControl1DockDrop(Sender: TObject;
Source: TDragDockObject; X, Y: Integer);
procedure ToolButton2Click(Sender: TObject);
procedure DialogEditor1DesignModeDropControl(sender: TObject; x,
y: Integer; ctrl: TControlInfo);
procedure DialogEditor1DeleteControl(Sender: TObject;
ctrl: TControlInfo);
procedure ToolButton1Click(Sender: TObject);
procedure DialogEditor1GetControlImage(Sender: TObject; tp: Integer;
const id: string; var Handle: HGDIOBJ);
procedure DoSpecialButtonClick (Sender : TObject);
private
fDetails : TDialogResourceDetails;
fPCWidth : Integer;
procedure FillPropertyBox (info : TControlInfo; reset : boolean);
procedure SaveResource (const undoDetails : string);
protected
procedure SetObject(const Value: TObject); override;
function GetCanDelete : Boolean; override;
public
procedure EditDelete; override;
end;
var
fmDialogResource: TfmDialogResource;
implementation
uses Variants, unitResourceDetails, unitResourceGraphics, unitExIcon, unitResourceMenus;
resourcestring
rstChangeProperty = 'change %s';
rstResize = 'resize';
rstAddControl = 'add control';
rstDeleteControl = 'delete control';
rstSetFont = 'set font';
{$R *.DFM}
{ TfmDialogResource }
(*----------------------------------------------------------------------*
| TfmDialogResource.SetObject |
| |
| Set to display a new dialog object |
*----------------------------------------------------------------------*)
procedure TfmDialogResource.SetObject(const Value: TObject);
begin
inherited;
fDetails := obj as TDialogResourceDetails;
DialogEditor1.ResourceTemplate := fDetails.Data.Memory;
tcPropertyKind.TabIndex := 0
end;
(*----------------------------------------------------------------------*
| TfmDialogResource.DialogEditor1Resize |
| |
| Dialog box has been resized. Adjust the rulers |
*----------------------------------------------------------------------*)
procedure TfmDialogResource.DialogEditor1Resize(Sender: TObject);
begin
inherited;
Ruler1.Width := DialogEditor1.Width;
Ruler2.Height := DialogEditor1.Height;
end;
(*----------------------------------------------------------------------*
| TfmDialogResource.DialogEditor1DesignModeSelectedItemChange |
| |
| A control has been selected. Find the control in the 'Controls' |
| combo, and set the properties to match the contol's |
*----------------------------------------------------------------------*)
procedure TfmDialogResource.DialogEditor1DesignModeSelectedItemChange(
Sender: TObject);
var
info : TControlInfo;
i : Integer;
begin
info := DialogEditor1.SelectedControl;
if Assigned (info) then
begin
for i := 0 to cbControls.Items.Count - 1 do
if info = TControlInfo (cbControls.Items.Objects [i]) then
begin
cbControls.ItemIndex := i;
cbControls.Hint := cbControls.Text;
break
end;
FillPropertyBox (info, True)
end
end;
(*----------------------------------------------------------------------*
| GetInfoDescription |
| |
| Get the description for a control to display in the 'controls' |
| combo. |
*----------------------------------------------------------------------*)
function GetInfoDescription (info : TControlInfo) : string;
var
idx : Integer;
begin
idx := Info.FindProperty (pkGeneral, 'Text');
if idx = -1 then
Result := Format ('%d %s', [info.ItemID, info.GetDescription])
else
Result := Format ('%d %s "%s"', [info.ItemID, info.GetDescription, info.PropertyValue [pkGeneral, idx]])
end;
(*----------------------------------------------------------------------*
| TfmDialogResource.DialogEditor1Show |
| |
| OnShow handler for the dialog editor. Called when the dialog editor |
| has created the dialog box, so we can read it's info and initialize |
| accordingly. NB We can't do this in 'SetObject' - the dialog box |
| hasn't been created then. |
*----------------------------------------------------------------------*)
procedure TfmDialogResource.DialogEditor1Show(Sender: TObject);
var
i : Integer;
info : TControlInfo;
begin
Ruler1.DialogBox := DialogEditor1.DialogHandle;
Ruler2.DialogBox := DialogEditor1.DialogHandle;
cbControls.Items.Clear; // Fill in the Controls combo
cbControls.Items.BeginUpdate;
try
info := DialogEditor1.DialogInfo;
cbControls.Items.AddObject (GetInfoDescription (info), info);
for i := 0 to DialogEditor1.ControlInfoCount - 1 do
begin
info := DialogEditor1.ControlInfo [i];
cbControls.Items.AddObject (GetInfoDescription (info), info);
end
finally
cbControls.Items.EndUpdate
end;
cbControls.ItemIndex := 0;
cbControls.Hint := cbControls.Text;
end;
(*----------------------------------------------------------------------*
| TfmDialogResource.cbControlsChange |
| |
| Select a control, based on the controls combo |
*----------------------------------------------------------------------*)
procedure TfmDialogResource.cbControlsChange(Sender: TObject);
var
info : TControlInfo;
begin
info := TControlInfo (cbControls.Items.Objects [cbControls.ItemIndex]);
cbControls.Hint := cbControls.Text;
DialogEditor1.SelectedControl := info
end;
(*----------------------------------------------------------------------*
| TfmDialogResource.PropertyListBox1PropertyChanged |
| |
| A property has been changed in the property list box. Update the |
| dialog editor. |
*----------------------------------------------------------------------*)
procedure TfmDialogResource.PropertyListBox1PropertyChanged(
Sender: TObject);
var
info : TControlInfo;
prop : TPropertyListProperty;
idx : Integer;
kind : TPropertyKind;
st : string;
begin
info := TControlInfo (cbControls.Items.Objects [cbControls.ItemIndex]);
prop := PropertyListBox1.Properties [PropertyListBox1.SelectedPropertyNo];
case tcPropertyKind.TabIndex of
1 : kind := pkStyle;
2 : kind := pkExtended
else
kind := pkGeneral
end;
st := prop.PropertyName;
idx := info.FindProperty (kind, st);
info.PropertyValue [kind, idx] := prop.PropertyValue; // nb. May make 'prop' invalid!!
st := Format (rstChangeProperty, [st]);
SaveResource (st);
end;
(*----------------------------------------------------------------------*
| TfmDialogResource.FillPropertyBox |
| |
| Fill the property list box with properties and their values for the |
| control. |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -