Board index » delphi » Updating Object Inspector Properties

Updating Object Inspector Properties


2007-02-28 07:54:52 PM
delphi262
Hello.
I am in the progress of making a component that has a property (Response)
that changes its class when another property (ResponseType) changes.
This works fine, however my problem is that when i change the ResponseType,
the Object Inspector is not aware of this, unless i select another component
on the form and then reselect my component.
How do i force the inspector to update its Component properties ?
Thanks
Jan
TJLTCPMessageSender = class(TComponent)
published // a lot of stuff removed....
Property ResponseType : TJLTCPResponsetypes read FResponseType write
SetResponseType;
Property Response : TJLBaseTCPMessageResponse read FResponse write
SetResponse;
end;
// Here we create the response class we want.....
procedure TJLTCPMessageSender.SetResponseType(const Value:
TJLTCPResponsetypes);
begin
FResponseType := Value;
If Response<>Nil Then
Response.Free;
case FResponseType of
trtNotDefined: ;
trtInteger: Response:=TJLTCPMessageIntegerResponse.Create(Self);
trtString: Response:=TJLTCPMessageStringResponse.Create(Self);
end;
If csDesigning in ComponentState Then
*** Maybe we want some "Force Object Inspector Update code here ***
end;
TJLBaseTCPMessageResponse = class(Tpersistent)
private
FOwner : TJLTCPMessageSender;
public
constructor Create(AOwner : TJLTCPMessageSender); Overload;Virtual;
end;
TJLTCPMessageIntegerResponse = class(TJLBaseTCPMessageResponse)
private
FIntResponse: Integer;
procedure SetIntResponse(const Value: Integer);
published
Property IntResponse : Integer read FIntResponse write SetIntResponse;
end;
TJLTCPMessageStringResponse = class(TJLBaseTCPMessageResponse)
private
FStrResponse: String;
procedure SetStrResponse(const Value: String);
published
Property StrResponse : String read FStrResponse write SetStrResponse;
end;
 
 

Re:Updating Object Inspector Properties

I forgot to say that i am using BDS2006.
"Jan Lund" <XXXX@XXXXX.COM>writes
Quote
Hello.

I am in the progress of making a component that has a property (Response)
that changes its class when another property (ResponseType) changes.

This works fine, however my problem is that when i change the
ResponseType, the Object Inspector is not aware of this, unless i select
another component on the form and then reselect my component.

How do i force the inspector to update its Component properties ?

Thanks
Jan

TJLTCPMessageSender = class(TComponent)
published // a lot of stuff removed....
Property ResponseType : TJLTCPResponsetypes read FResponseType write
SetResponseType;
Property Response : TJLBaseTCPMessageResponse read FResponse write
SetResponse;
end;

// Here we create the response class we want.....
procedure TJLTCPMessageSender.SetResponseType(const Value:
TJLTCPResponsetypes);
begin
FResponseType := Value;
If Response<>Nil Then
Response.Free;

case FResponseType of
trtNotDefined: ;
trtInteger: Response:=TJLTCPMessageIntegerResponse.Create(Self);
trtString: Response:=TJLTCPMessageStringResponse.Create(Self);
end;

If csDesigning in ComponentState Then
*** Maybe we want some "Force Object Inspector Update code here ***
end;

TJLBaseTCPMessageResponse = class(Tpersistent)
private
FOwner : TJLTCPMessageSender;
public
constructor Create(AOwner : TJLTCPMessageSender); Overload;Virtual;
end;

TJLTCPMessageIntegerResponse = class(TJLBaseTCPMessageResponse)
private
FIntResponse: Integer;
procedure SetIntResponse(const Value: Integer);
published
Property IntResponse : Integer read FIntResponse write SetIntResponse;
end;

TJLTCPMessageStringResponse = class(TJLBaseTCPMessageResponse)
private
FStrResponse: String;
procedure SetStrResponse(const Value: String);
published
Property StrResponse : String read FStrResponse write SetStrResponse;
end;



 

Re:Updating Object Inspector Properties

Jan Lund writes:
Quote
This works fine, however my problem is that when i change the ResponseType,
the Object Inspector is not aware of this, unless i select another component
on the form and then reselect my component.
I would try calling IOTAComponent.Select on your component and see if
that forces a refresh.
Erik