📄 ceexp.pas
字号:
unit CeExp;
interface
uses
Classes, DsgnIntf, DdhGraph, Messages, Forms, Controls;
type
TCeExpert = class (TComponentEditor)
public
function GetVerbCount: Integer; override;
function GetVerb(Index: Integer): string; override;
procedure ExecuteVerb(Index: Integer); override;
end;
// modified class, to allow design time mouse operations
// to reach both the component and the form designer
// depending on the operation
type
TDdhDesignGraph = class(TDdhGraph)
public
constructor Create (Owner: TComponent); override;
procedure CmDesignHitTest (var Msg: TWMMouse);
message cm_DesignHitTest;
end;
procedure Register;
implementation
uses
WizForm, Windows, Dialogs, SysUtils;
function TCeExpert.GetVerbCount: Integer;
begin
Result := 1;
end;
function TCeExpert.GetVerb (Index: Integer): string;
begin
if Index = 0 then
Result := 'Graph Component &Expert...';
end;
procedure TCeExpert.ExecuteVerb (Index: Integer);
begin
if Index = 0 then
begin
FormCeExp := TFormCeExp.Create (Application);
try
with Component as TDdhGraph do
begin
// initialize the target component
FormCeExp.DdhGraph1.DefaultText := DefaultText;
FormCeExp.DdhGraph1.Font := Font;
FormCeExp.DdhGraph1.LinesColor := LinesColor;
FormCeExp.DdhGraph1.Points.Assign (Points);
// initialize the editors
FormCeExp.EditDefText.Text := DefaultText;
FormCeExp.FontDialog1.Font := Font;
end;
// show the modal form
if FormCeExp.ShowModal = mrOK then
// retrieve the results
with Component as TDdhGraph do
begin
// set the properties of the target component
DefaultText := FormCeExp.DdhGraph1.DefaultText;
Font := FormCeExp.DdhGraph1.Font;
Color := FormCeExp.DdhGraph1.Color;
LinesColor := FormCeExp.DdhGraph1.LinesColor;
Points.Clear;
Points.Assign (FormCeExp.DdhGraph1.Points);
Repaint;
Designer.Modified;
end;
finally
FormCeExp.Free;
end;
end;
end;
// class TDdhDesignGraph
constructor TDdhDesignGraph.Create (Owner: TComponent);
begin
inherited Create (Owner);
// remove the flag...
ControlStyle := ControlStyle - [csDesignInteractive];
end;
procedure TDdhDesignGraph.CmDesignHitTest (var Msg: TWMMouse);
begin
if (Msg.Keys and mk_Control) <> 0 then
// interactive desing
Msg.Result := 1
else
// default designer behavior
Msg.Result := 0;
end;
procedure Register;
begin
RegisterComponents ('DDHB', [TDdhDesignGraph]);
RegisterComponentEditor (TDdhGraph, TCeExpert);
RegisterComponentEditor (TDdhDesignGraph, TCeExpert);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -