What is the correct place/time to start subclassing a control?
What is the proper time to restore the original window proc?
Right now i subclass during form creation:
procedure TForm1.FormCreate(Sender: TObject);
begin
FOldPanel1WindowProc := Panel1.WindowProc;
Panel1.WindowProc := Panel1WindowProc;
end;
and i restore the subclassing during form destruction:
procedure TForm1.FormDestroy(Sender: TObject);
begin
Panel1.WindowProc := FOldPanel1WindowProc;
end;
This works fine, as long as i don't use ThemeManager, which subclasses controls itself. As soon as a try to subclass a control that ThemeManager also sub-classes, i get very nasty errors.
i assume it's becuase i should not start the subclass during Create and restore it during Destroy. So what is the properly documented time to subclass and unsubclass a control in Delphi?