Solved

Get the text representation of DFM info of a component

Posted on 1998-06-22
6
397 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
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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 100 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now