Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get the text representation of DFM info of a component

Posted on 1998-06-22
6
Medium Priority
?
417 Views
Last Modified: 2010-04-04
I need to get the text representation of the DFM info of a single component (let's say a TQuery or a TQuickRep).
How can I do this? I need code.
Please Help.
0
Comment
Question by:Mak042298
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Expert Comment

by:kjteng
ID: 1355281
You do not need any coding:-
use the mouse to select a component on the form
click edit copy from IDE menu
go to any editor page (eg press F12), click edit and paste
the text representation will be pasted

0
 
LVL 2

Expert Comment

by:kjteng
ID: 1355282
You do not need any coding:-
     use the mouse to select a component on the form
     click edit copy from IDE menu
     go to any editor page (eg press F12), click edit and paste
     the text representation will be pasted

Let me know if I have interpret you question incorrectly
0
 
LVL 10

Expert Comment

by:Jacco
ID: 1355283
Here is a simple example. The resulting text is not excatly the same as the "view as text" options but most of the properties are shown. The exact difference I don't know, I think this is the best you can get. It uses the ObjectResourceToText function in the unit Classes. (The other option is ObjectBinaryToText you have to save using WriteComponent then).

*** Start of code

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
  strIn, strOut : TMemoryStream;
begin
  strIn:=TMemoryStream.Create;
  strOut:=TMemoryStream.Create;
  try
    strIn.WriteComponentRes('',Form1);
    strIn.Position := 0;
    ObjectResourceToText(strIn,strOut);
    strOut.Position:=0;
    Memo1.Lines.LoadFromStream(strOut);
  finally
    strIn.Free;
    strOut.Free;
  end;
end;

end.

*** end of code

*** start of code

object Form1: TForm1
  Left = 200
  Top = 108
  Width = 435
  Height = 300
  Caption = 'Form1'
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  PixelsPerInch = 96
  TextHeight = 13
  object Memo1: TMemo
    Left = 0
    Top = 8
    Width = 425
    Height = 169
    Lines.Strings = (
      'Memo1')
    TabOrder = 0
  end
  object Button1: TButton
    Left = 176
    Top = 192
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 1
    OnClick = Button1Click
  end
end

*** end of code

This code does it for the form. But you can use any component...

Just too late for the points..... grrrr...

I'll post it anyway..... :(
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:hrizal
ID: 1355284
Here, i write the function for you.


Function ReadDFM(dfmName : String) : String;
var Source,
    Destination  : TStream;
    Temp         : TStringList;
   
begin
  Source      := TFileStream.create(dfmName,fmOpenread);
  Destination := TFileStream.Create('temp$$$',fmCreate);
  // add more point please ...
  ObjectResourceToText(Source,Destination);
  Source.Free;
  Destination.Free;
  temp := TStringList.Create;
  temp.LoadFromFile('temp$$$');
  result := temp.text;
  free.temp;
end;

0
 

Author Comment

by:Mak042298
ID: 1355285
OK, Jacco your solution worked just as I expected. Send it again and  I'll give you an A.
Sorry kjteng, but your solution is very simply.
0
 

Accepted Solution

by:
keksperte earned 200 total points
ID: 1355286
Why not have a look to the gifts?

I wish to say:

there in the DELPI\BIN Path, ther is a little program called CONVERT.EXE
I please you to try it. Because:

Convert Unit1.DFM  gives you a Unit1.Txt and   ( you can use masking as *.dfm)
Convert Unit1.TXT   makes a new/old Form Unit1.DFM
!!! It overwrites !!!

Its nice, isn't it ?

Be heapy. A Kekspert.

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question