interface(インターフェース)を自分で作成して、
クラスに持っているかを判定したい場合、GetInterfaceEntry を
使用します。
as を使用したい場合には、interface に GUID を埋め込んで置く必要があります。
IDEのソース上で GUID を埋め込みするには、[Ctrlキー] + [Shiftキー] + [Gキー] を
キー入力します。
type
IDWSShapeContainer = interface
['{8D26C9EF-AD7A-4A6F-B145-BBEBC2D85240}']
function IsShapeFocused():Boolean;
end;
TDWSBoxFlowDiagram = class(TPanel, IDWSShapeContainer)
:
end;
procedure TDWSShape.PaintSelectFocus(ACanvas: TCanvas);
var
container: IDWSShapeContainer;
begin
// nil 以外なら持っている。nil なら持っていない
if Self.Parent.GetInterfaceEntry(IDWSShapeContainer) <> nil then
begin
container := Self.Parent as IDWSShapeContainer;
if not container.IsShapeFocused() then
begin
exit;
end;
end;
:
end;
0 件のコメント:
コメントを投稿