LucieLastic
Programmer
hi All
How do you add a TForm to a TList as a pointer then access it later eg:-
FormCaption := TForm(MyList[idx]).Caption;
or
TForm(MyList[idx]).Free;
I was trying to add the forms to the list like this:-
MyList.add(@NewForm) - is this right?
Also, I want to pass the pointer to other methods and having trouble with type mismatches.
I tried a method declaration like this but the Indexof fails and it's definitely in the list - think the 'pointer' bit in declaration is wrong.
procedure Tmain.RemoveFormFromList(FrmPtr: pointer);
var idx : integer;
begin
idx := WindowList.IndexOf(FrmPtr); <---This is always -1
if idx > -1 then
WindowList.Delete(idx);
end;
I seem to get one bit right then another bit fails. All I want to do is have a TList of open forms and later find these forms in my list (using IndexOf) and delete them from the list aswell as Free them using the Form's pointer.
ta
lou
p.s. I was using the api call DestroyWindow but although this worked, it didn't call the destructors of my forms.
How do you add a TForm to a TList as a pointer then access it later eg:-
FormCaption := TForm(MyList[idx]).Caption;
or
TForm(MyList[idx]).Free;
I was trying to add the forms to the list like this:-
MyList.add(@NewForm) - is this right?
Also, I want to pass the pointer to other methods and having trouble with type mismatches.
I tried a method declaration like this but the Indexof fails and it's definitely in the list - think the 'pointer' bit in declaration is wrong.
procedure Tmain.RemoveFormFromList(FrmPtr: pointer);
var idx : integer;
begin
idx := WindowList.IndexOf(FrmPtr); <---This is always -1
if idx > -1 then
WindowList.Delete(idx);
end;
I seem to get one bit right then another bit fails. All I want to do is have a TList of open forms and later find these forms in my list (using IndexOf) and delete them from the list aswell as Free them using the Form's pointer.
ta
lou
p.s. I was using the api call DestroyWindow but although this worked, it didn't call the destructors of my forms.