Solved

adding onchange event at runtime

Posted on 2002-06-19
7
508 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
lucky geo ;-)
0
 
LVL 17

Expert Comment

by:geobul
Comment Utility
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
Comment Utility
just about
>so i flipped the coin

;-)
0
 

Author Comment

by:urif
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now