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

x
?
Solved

Delphi Programming question

Posted on 1997-08-30
12
Medium Priority
?
144 Views
Last Modified: 2010-04-04
Hi,

I want to copy the text selected in one memo (memo1 on form2) and paste it into another memo1 (on form1) using a button on form2. I only want the text to be added to the memo on form1, not replace the text currently in there. How would I do that? I can email you the program if you want.

Thanks for your help.
0
Comment
Question by:ecastle
[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
12 Comments
 
LVL 2

Expert Comment

by:icampbe1
ID: 1343109
Use the AddStrings method if the target memo:

MemoTarget.Lines.AddStrings( MemoSource.Lines );

The lines of a memo are of type TStrings, so you can work with the properties and methods of TStrings.  You also can use  SelText etc. as they are in the Memo's ancestry.

Cheers,
Ian C.
0
 

Author Comment

by:ecastle
ID: 1343110
I'm not sure I understand. I gave you the name and places of all the components, so if you give me exactly the code to use you can have 100 points :)
0
 

Author Comment

by:ecastle
ID: 1343111
I've worked it out now with the help of people on IRC. Thanks anyway Ian, but your answer was no help :P
0
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!

 
LVL 5

Expert Comment

by:ronit051397
ID: 1343112
this is an example with 2 memos on the same form, it is suppossed to work also with different forms:

procedure TForm1.Button1Click(Sender: TObject);
begin
  memo1.copytoclipboard;
  memo2.setfocus;
  memo2.pastefromclipboard;
end;
0
 

Author Comment

by:ecastle
ID: 1343113
As I said, I have solved it. My problem was that I had to include the unit call in a second 'uses' after 'implementation', instead of the one at the top of the source.
0
 

Expert Comment

by:krisz
ID: 1343114
I have absolutely no comments.
0
 
LVL 4

Expert Comment

by:itamar
ID: 1343115
You must to include the second unit in the implementation uses clause to have access to its objects.
If you are done with this question accept an answer and quit.
0
 

Author Comment

by:ecastle
ID: 1343116
Isn't there a way to cancel my question? I worked it out with the help of someone on irc. Nobody here provided me with a satisfactory answer. Why should I pay the points?
0
 
LVL 4

Expert Comment

by:itamar
ID: 1343117
The question was not well formulated. The problem you described make people think about especific methods of TMemo and so on. I advise you to learn the basics of Delphi programming (or anything else) before submiting your questions in a expertise site. You have the news and chats to go. At least you can remove your question following the instructions on:

http://www.experts-exchange.com/info/DelQuestion.htm
0
 

Author Comment

by:ecastle
ID: 1343118
When you are learning something as complex as Delphi with just the program and no documentation or tutorials to help you it's hard to know everything... sorry I'm not as skilled as you.
0
 

Expert Comment

by:kimfriis
ID: 1343119
No documentation?? Are you using a illegal copy of Delphi??
0
 
LVL 2

Accepted Solution

by:
Waldek earned 100 total points
ID: 1343120
This is seceond unit
unit memo1;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
 Show;
end;

end.

and this is first unit

unit memo2;

interface

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

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

var
  Form2: TForm2;

implementation
uses memo1;

{$R *.DFM}

procedure TForm2.Button1Click(Sender: TObject);
begin
  memo1.copytoclipboard;
  Form1.memo1.setfocus;
  Form1.memo1.pastefromclipboard;
end;

end.

and project

program memo;

uses
  Forms,
  memo1 in 'memo1.pas' {Form1},
  memo2 in 'memo2.pas' {Form2};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm2, Form2);
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

Maybe this

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

715 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