FS#5 - Fonction nouveau skin
Concerne le projet:
Framework 020 - CONTROLS-VISUELS
Ouverte par Loic Le Gallou (loic) - samedi, 31 mars 2007, 18:18 GMT+2
Dernière édition par Loic Le Gallou (loic) - jeudi, 01 novembre 2007, 20:01 GMT+2
Ouverte par Loic Le Gallou (loic) - samedi, 31 mars 2007, 18:18 GMT+2
Dernière édition par Loic Le Gallou (loic) - jeudi, 01 novembre 2007, 20:01 GMT+2
|
DétailsFonction nouveau skin
|
Cette tâche dépend de
Qq pb si on l'applique a un WinControl (les composants contenus sont perdus)
a adapter pour recharger l'ensemble d'une form (boucle pour le pas reallouer la fenetre pour chaque composant)
procedure ReloadControl2(var ctrlref);
function FindControl(f : TWinControl; name : string) : TControl;
Var
i : integer;
begin
result := nil;
i := 0;
while (i < f.ComponentCount) and (f.Components[i].Name <> name) do
inc(i);
if (i < f.ControlCount) then
if (f.Components[i] is TControl) then
result := f.Components[i] as TControl;
end;
Var
New_CtrlOwner : TWinControl; //TForm;
ctrl : TControl;
CtrlOwnerClass : TWinControlClass; // TFormClass;
CtrlOwner : TComponent; //TForm;
CtrlName : string;
CtrlParent : TWinControl;
begin
ctrl := TControl(ctrlref);
ctrlname := ctrl.name;
ctrlparent := ctrl.parent;
// creation nouvelle fenetre
ctrlowner := ctrl.owner;
CtrlOwnerClass := TWinControlClass(ctrlowner.ClassType);
New_CtrlOwner := CtrlOwnerClass.Create(ctrlowner);
try
// suppression et desallocation controle d'origine
ctrlowner.RemoveComponent(ctrl);
ctrl.Free;
// suppression nouveau controle de sa fenetre
ctrl := FindControl(New_CtrlOwner, ctrlname); //frm.Edit1;
New_CtrlOwner.RemoveComponent(ctrl); //frm.Edit1);
// ajout controle de la nouvelle fenetre dans celle d'origine
TControl(ctrlref) := ctrl;
ctrlowner.InsertComponent(ctrl);
ctrl.Parent := ctrlparent; //f;
finally
New_CtrlOwner.Free;
end;
end;