Mahsa60
asked on
Find Form Name
Hi
I'm using Delphi 7 .
I wanna build a template form that other forms inherit from it .
i wanna do some work with Form Name in template form (i need name of form) that inherited forms do it for itself .
for example i wanna Disabled all component in form and i need from name to do that :
for i := 0 to AOtherForm.ComponentCount- 1 do
begin
if (AOtherForm.Components[i] is TDBEdit) then
TEdit(AOtherForm.Component s[i]).Enab led := True;
if (AOtherForm.Components[i] is TDBComboBox) then
TComboBox(AOtherForm.Compo nents[i]). Enabled := True;
end;
//AOtherForm is a variable that contains form name.
how can i get the name of a form to fill AOtherForm ?
I'm using Delphi 7 .
I wanna build a template form that other forms inherit from it .
i wanna do some work with Form Name in template form (i need name of form) that inherited forms do it for itself .
for example i wanna Disabled all component in form and i need from name to do that :
for i := 0 to AOtherForm.ComponentCount-
begin
if (AOtherForm.Components[i] is TDBEdit) then
TEdit(AOtherForm.Component
if (AOtherForm.Components[i] is TDBComboBox) then
TComboBox(AOtherForm.Compo
end;
//AOtherForm is a variable that contains form name.
how can i get the name of a form to fill AOtherForm ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you make it a method of the Form it looks like this:
interface
type
TMyForm = class(TForm)
...
procedure Enable_Items(status :boolean);
end;
implementation
procedure TMyForm.Enable_Items(statu s :boolean);
var i:integer;
begin
if status then
begin
for i := 0 to ComponentCount-1 do
begin
if (Components[i] is TDBEdit) then
TEdit(Components[i]).Enabl ed := True;
if (Components[i] is TDBComboBox) then
TComboBox(Components[i]).E nabled := True;
end;
end;
end;
If you have this working you can use FormInheritance to inherit other forms from this form.
To do this in Delphi choose "File / New / Other ..." select the tab with the projects name on it an select your base form.
The new form will be a descendant of you created enhanced form. You can create as much descendants as you like. They will all have the new method Enable_Items
Regards Jacco
interface
type
TMyForm = class(TForm)
...
procedure Enable_Items(status :boolean);
end;
implementation
procedure TMyForm.Enable_Items(statu
var i:integer;
begin
if status then
begin
for i := 0 to ComponentCount-1 do
begin
if (Components[i] is TDBEdit) then
TEdit(Components[i]).Enabl
if (Components[i] is TDBComboBox) then
TComboBox(Components[i]).E
end;
end;
end;
If you have this working you can use FormInheritance to inherit other forms from this form.
To do this in Delphi choose "File / New / Other ..." select the tab with the projects name on it an select your base form.
The new form will be a descendant of you created enhanced form. You can create as much descendants as you like. They will all have the new method Enable_Items
Regards Jacco
ASKER
tell me if i am wrong
tanxfull
Mahsa
i'm working like this but i wanna change it and put all codes into the template form .
//this procedure is in my MAIN form
procedure Enable_Items(AOtherForm : TForm;status :boolean);
var i:integer;
begin
if status then
begin
for i := 0 to AOtherForm.ComponentCount-
begin
if (AOtherForm.Components[i] is TDBEdit) then
TEdit(AOtherForm.Component
if (AOtherForm.Components[i] is TDBComboBox) then
TComboBox(AOtherForm.Compo
end;
end;
end;
//this code is in Registry form
procedure TF_Registry.BitBtn1Click(S
begin
Enable_Items(F_Registry,Tr
end;