Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get properties of component

Status
Not open for further replies.

keenanbr

Programmer
Oct 3, 2001
469
IE
Hi,
I am trying to write a procedure which will read all the Data Access components on a Form.

So far I have managed to list all the components and each components properties.

I haven't been able to get the values of the properties and I haven't been able to identify which ones are Data Access components.

Any help appreciated.
 
I have managed to get the values of the properties. I just need to be able to identify which are Data Access components. Obviously, I could do an if then else for each type. Hoping there is a better way.
 
you can do this:

Code:
for i := yourform.ComponentCount - 1 downto 0 do 
begin 
  if yourform.Components[i] is TYourDataClass then 
   begin
    // do whatever you need to do, for example:
    TYourDataClass(yourform.Components[i]).WhateverProperty := SomeValue;    
   end;
end;

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks, I realized I could do this. I was hoping I could do something like;

if yourform.Components.ClassType is DataAccess then
 
well I think I showed you this?

please post your .dfm file and I will give a more concrete example.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
here's what I've done.
Code:
for i := 0 to Application.ComponentCount - 1 do
    begin
         if Application.Components[i] is TForm then
         begin
              WriteLn(myFile, Application.Components[i].Name + ',' +  Application.Components[i].ClassName);
              WriteLn(myFile, '=======================,======================');

              for j := 0 to Application.Components[i].ComponentCount - 1 do
              begin
                   //ShowMessage(Components[i].Name + ',' +  Components[i].ClassName);
                   thisComponent := Application.Components[i].Components[j];
                   if (thisComponent is TDataSource) or (thisComponent is TProvider) or (thisComponent is TStoredProc) then
                   begin
                        ListComponentProperties(thisComponent, myFile);
                   end;
              end;
       end;
   end;

here's the dfm

Code:
object Form1: TForm1
  Left = 184
  Top = 108
  Width = 870
  Height = 640
  Caption = 'Form1'
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 80
    Top = 304
    Width = 89
    Height = 41
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Panel1: TPanel
    Left = 256
    Top = 112
    Width = 521
    Height = 249
    Caption = 'Panel1'
    TabOrder = 1
  end
  object DataSource1: TDataSource
    DataSet = StoredProc1
    Left = 80
    Top = 24
  end
  object StoredProc1: TStoredProc
    DatabaseName = 'DBDEMOS'
    SessionName = 'Default'
    Left = 344
    Top = 168
  end
  object Provider1: TProvider
    DataSet = StoredProc1
    Left = 32
    Top = 24
  end
  object DataSource2: TDataSource
    Left = 472
    Top = 168
  end
end

It all works fine. What I'd really like to do is get these details from another project. Any ideas?
 
sure,

will you have access to the actual source code files (.pas, .dfm), or is the input a compiled delphi project (.exe)

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
I have access to the .pas, .dfm. I'm currently looking at parsing these for the required information. Is that the way to go?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top