Solved

adding onchange event at runtime

Posted on 2002-06-19
7
533 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
  • 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
Industry Leaders: 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

Industry Leaders: 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

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 142
creating threads in delphi 1 157
Delphi Yen format 3 58
How to Get Images From Server using App Tethering 11 42
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

713 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