Solved

Inserting text into an app.

Posted on 1998-02-23
7
132 Views
Last Modified: 2010-08-05
I am writing an application which needs to act as a
text editor, but also be able to insert specific lines of
text when a menu item is selected. The inserted text needs
to then behave as if it were entered by the user ie. the
user should then be able to delete, add to, or alter the
text in any way. Anyone know how?
afterwards if neccesary.
0
Comment
Question by:kh5395
  • 4
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
inter earned 20 total points
ID: 1359727
1 - Just open a new project
2 - Place a button and TMemo component on form
3 - dblclick on button. and write the following in between
    Memo1.Lines.Add('This is the interted line');
4 - Run the project
5 - type in some lines in memo
6 - press the button
7 - For doing this by menu write down the same or similiar code to the menus click method normally

Is it OK
Igor
0
 

Author Comment

by:kh5395
ID: 1359728
Igor,
     That's exactly what I needed to do. However, my problem is
that I have several dialog boxes. These all need to take data
from the user and then display a piece of text.
     e.g. one box asks the user to choose a style, each of which
is listed as a radio box. The dialog box unit then needs to
display this information on the TMemo. My problem now is that
I can't get at the TMemo because it is in the main unit. Could
you tell me how to do this? I tried putting the main unit in the
'uses' declaration, but it says this is a circular statement.
I would really appreciate your help.
Thanks again,
Nik



0
 

Author Comment

by:kh5395
ID: 1359729
Igor,
     That's exactly what I needed to do. However, my problem is
that I have several dialog boxes. These all need to take data
from the user and then display a piece of text.
     e.g. one box asks the user to choose a style, each of which
is listed as a radio box. The dialog box unit then needs to
display this information on the TMemo. My problem now is that
I can't get at the TMemo because it is in the main unit. Could
you tell me how to do this? I tried putting the main unit in the
'uses' declaration, but it says this is a circular statement.
I would really appreciate your help.
Thanks again,
Nik



0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:kh5395
ID: 1359730
Igor,
     That's exactly what I needed to do. However, my problem is
that I have several dialog boxes. These all need to take data
from the user and then display a piece of text.
     e.g. one box asks the user to choose a style, each of which
is listed as a radio box. The dialog box unit then needs to
display this information on the TMemo. My problem now is that
I can't get at the TMemo because it is in the main unit. Could
you tell me how to do this? I tried putting the main unit in the
'uses' declaration, but it says this is a circular statement.
I would really appreciate your help.
Thanks again,
Nik



0
 
LVL 5

Expert Comment

by:inter
ID: 1359731
Try forming a uses clause in the implementation that is

unit2

interface
...

implementation

uses
  Unit1;
...

Ok?
Igor
0
 

Author Comment

by:kh5395
ID: 1359732
Igor,

I've tried that, but it doesn't seem to work :

unit Main;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, Menus, StdCtrls, docclsdg;

type
  TMainForm = class(TForm)
    ...
    ...
    ...

    procedure RunLaTeX1Click(Sender: TObject);
    procedure Class1Click(Sender: TObject);
    procedure InsertText(var S: String);
 
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation

{$R *.DFM}

procedure TMainForm.RunLaTeX1Click(Sender: TObject);
begin
WinExec('Latex',SW_SHOWMAXIMIZED);
end;

procedure TMainForm.Class1Click(Sender: TObject);
begin
     docclassdlg.ShowModal;
end;

procedure TMainForm.InsertText(var S: string);
begin
     MainForm.EditPad.Lines.Add(S);
end;
end.

****************

unit Docclsdg;

interface

uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
  StdCtrls, ExtCtrls;

type
  Tdocclassdlg = class(TForm)
    OKBtn: TBitBtn;
    CancelBtn: TBitBtn;
    HelpBtn: TBitBtn;
    Bevel1: TBevel;
    RadioGroup1: TRadioGroup;
    Label1: TLabel;
    procedure OKBtnClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  docclassdlg: Tdocclassdlg;

implementation
uses
    Main;
{$R *.DFM}

procedure Tdocclassdlg.OKBtnClick(Sender: TObject);
begin
     InsertText('Inserted Text');
end;

end.


I get a syntax error when it tries to run InsertText. Any idea
why?
Thanks, Nik.

0
 
LVL 5

Expert Comment

by:inter
ID: 1359733
Hi,

When you call one class method from another, you should specify the class name before the method just as refering a member of a record so

InsertText('Inserted Text') should be
MainForm.InsertText('Inserted Text') is this ok?

Igor
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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