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

x
?
Solved

adding onchange event at runtime

Posted on 2002-06-19
7
Medium Priority
?
547 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 400 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
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