?
Solved

Inserting text into an app.

Posted on 1998-02-23
7
Medium Priority
?
139 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
[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
  • 4
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
inter earned 40 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Independent Software Vendors: 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!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 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