Solved

adding onchange event at runtime

Posted on 2002-06-19
7
525 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

832 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