我有一个从TGraphicControl下降的自定义Delphi组件.它的类声明如下:
TMyLabel = class(TGraphicControl)
private
...
protected
...
public
...
published
property Height;
property Width write SetWidth;
...
end;
Run Code Online (Sandbox Code Playgroud)
SetWidth的实现更进一步:
procedure TMyLabel.SetWidth(const Value: Integer);
begin
if (Value >= 0) and (Value <> Width)
then begin
inherited Width := Value;
// Do some other stuff
...
end;
MessageDlg('Test', mtInformation, [mbOK], 0);
end;
Run Code Online (Sandbox Code Playgroud)
当组件的宽度在运行时或在设计时通过在对象检查器的相应字段中输入值而以编程方式更改时,我当前调用了SetWidth.但是,当我在设计时使用鼠标调整组件大小时,对象检查器"宽度"字段会更新,但不会显示消息框,因此不会调用我的SetWidth过程.
我需要在鼠标调整组件大小时调用SetWidth,以便我可以为Paint过程设置一个标志,以便知道何时必须执行其他操作(除了重新绘制组件之外).有没有办法实现这个目标?