Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>
TParamCheckList
Using custom inplace editors
Using custom inplace editors
Using custom inplace editors is possible with the Parameter controls but require some preparing of the inplace editor to be used correct. The custom inplace editor is invoked with the style ‘CUSTOM’, ie:
Parameter control events
When the custom inplace editor is about to be edited, the event OnParamCustomEdit is triggered with parameters:
For TParamLabel:
TParamCustomEditEvent = procedure(Sender: TObject; href, value, props: string; EditRect: TRect) of object;
TParamCustomEditEvent = procedure(Sender: TObject; idx: Integer; href, value, props: string; EditRect: TRect) of object;
TParamCustomEditEvent = procedure(Sender: TObject; Node: TTreeNode; href, value, props: string; EditRect: TRect) of object;
From this event, following code can be used to show the custom inplace edit control:
mycustomcontrol.Parent := Sender; mycustomcontrol.left := EditRect.Left; mycustomcontrol.Top := EditRect.Top; mycustomcontrol.Text := value; mycustomcontrol.Param := href; mycustomcontrol.OnUpdate := (Sender as TParamlabel).ControlUpdate; mycustomcontrol.Visible := true; mycustomcontrol.SetFocus;
procedure ControlUpdate(Sender: TObject; Param,Text:string);
Preparing the inplace edit control
Create a descendent component of the inplace edit control with following properties and events:
TParamUpdateEvent = procedure(Sender: TObject; Param, Text: string) of object; TMyCustomControl = class(TMyControl) private FParam: string; FOnUpdate: TParamUpdateEvent; procedure WMActivate(var Message: TWMActivate); message WM_ACTIVATE; protected procedure DoExit; override; procedure CreateParams(var Params: TCreateParams); override; public property Param: string read FParam write FParam; property OnUpdate: TParamUpdateEvent read FOnUpdate write FOnUpdate; end;
{ TMyCustomControl } procedure TMyCustomControl.CreateParams(var Params: TCreateParams); begin inherited; with Params do Style := Style AND NOT WS_CHILD OR WS_POPUP; end; procedure TMyCustomControl.DoExit; begin inherited; if Assigned(OnUpdate) then OnUpdate(Self,Param,Text); end; procedure TMyCustomControl.WMActivate(var Message: TWMActivate); begin inherited; if Message.Active = 0 then Hide; end;