Link to home
Start Free TrialLog in
Avatar of djadja
djadja

asked on

inheriting from a TListview and creating coluimns in the OnCreate

I have inherited a new component 'TLogView' from the TListView.  I have setup various 'extras' in the OnCreate and I need to create some columns.  I tried to do this in the OnCreate and I get Control "" has no parent window when I try to add the component to a form.  I tried to override the Loaded method (as according to the help this is where you would do any additional initialization after all properties have been streamed in) like so:
procedure TLogView.Loaded;
begin
  inherited Loaded;
  CreateMyCols;
end;

but creating a TLogView in the OnCreate of the form and even after setting the Parent, it does not call Loaded!

Can anyone help
Avatar of Lischke
Lischke

Loaded will be called in any case where the component is instantiated with one exception: If the control is just dropped on the form in the IDE. The reason is at this point there's nothing to load from the component resource yet as all properties are just in their default state. I suggest that you override CreateWnd and after you called the inherited method you can do any initialization you like.

Ciao, Mike
Avatar of djadja

ASKER

This seems to have worked - thanks - but is this the usual way of doing stuff that you can't (or don't want to) do in the OnCreate?
ASKER CERTIFIED SOLUTION
Avatar of Lischke
Lischke

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of djadja

ASKER

I also program for a living! - Thanks again.