Solved

adding onchange event at runtime

Posted on 2002-06-19
7
540 Views
Last Modified: 2010-04-04
i'm creating several trichedits at run time, is there a way to create an onchange event that takes as parameter the current (the one with the focus) trichedit?

basically, i want to handle that if user writes then the caption of the form changes.

also, i noticed that by creating the richedit at run time the default popupmenu, the one with copy, paste.... is not created, any way to do this?

thanks
0
Comment
Question by:urif
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7094905
didn't know yet,
if a richedit has an onchange-event,
but you can use the onkeypress-event

the sender holds the current so you could do
something like this

if (sender is trichedit) then
begin
  caption := TRichedit(sender).name; //for example
  ...
end;

to assign a event procedure

r := trichedit.create(self)
r.onkeypress := MyPreDefinedKeyPressMethod;

just from head

meikl ;-)

0
 
LVL 17

Accepted Solution

by:
geobul earned 100 total points
ID: 7094963
Hi,
1.Just to expand Meikl's code:
---
type
  TForm1 = class(TForm)
    procedure REChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  re1: TRichEdit;

implementation

{$R *.DFM}

procedure TForm1.REChange(Sender: TObject);
begin
  // your code
  if (Sender is TRichEdit) then
    ShowMessage((Sender as TRichEdit).Name + ' was changed');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  re1 := TRichEdit.Create(Form1);
  with re1 do begin
    Parent := Form1;
    Name := 're1';
    Left := 100;
    Top := 100;
    OnChange := REChange;
  end;
end;
---
2. I'm afraid I have no default popup menu in both design and run-time created richedits.

Regards, Geo
0
 

Author Comment

by:urif
ID: 7095173
they were both good asnwer, and i didn't know whom to give the points so i flipped the coin. thanks for your help!
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 27

Expert Comment

by:kretzschmar
ID: 7095212
lucky geo ;-)
0
 
LVL 17

Expert Comment

by:geobul
ID: 7095495
What could I say? I definately didn't count on getting any points. And I didn't know that I had such luck :-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7095513
just about
>so i flipped the coin

;-)
0
 

Author Comment

by:urif
ID: 7095541
ok, ok

i'll post a fake question and i give you the points too.

look for "fake question" as a title
0

Featured Post

Technology Partners: 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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 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