Solved

Inserting text into an app.

Posted on 1998-02-23
7
129 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
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…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

22 Experts available now in Live!

Get 1:1 Help Now