Board index » delphi » REQ: Help creating a edit box at run time sample enclosed plus error received

REQ: Help creating a edit box at run time sample enclosed plus error received

var ed:tedit;

begin
ed:=tedit.create(self); {plus i've tried handle,application,form1}
ed.top:=100;
ed.left:=100;
ed.text:='';
ed.setfocus;

{bit of stuff to do with editing}

ed.destroy;

error i received

EInvalidoperation with message 'CONTROL' has no parent window

can anyone please tell me how to display my edit box.

Thanks in Advance

check my books nothing seems to explain correctly how to create at run
time on the main form

Karl

 

Re:REQ: Help creating a edit box at run time sample enclosed plus error received


Op Sun, 14 Nov 1999 15:57:28 +0000 schreef Karl Ryan in
alt.comp.lang.borland-delphi ...
Quote
>error i received
>EInvalidoperation with message 'CONTROL' has no parent window
>can anyone please tell me how to display my edit box.

Just like it says: set the parent!
var
  ed : Tedit;
begin
  ed := Tedit.Create(Form1);
  ed.parent := Form1;
  etc.
end;

Advantage with telling who the owner is, is that you don't have to free
it yourself. Form1 as Owner is responsible for this!

Matthijs.
--
What's in a sig?
Would a sig sound as sweet, if it wasnot called a sig?

Re:REQ: Help creating a edit box at run time sample enclosed plus error received


Karl Ryan schrieb:

Quote

> var ed:tedit;

> begin
> ed:=tedit.create(self); {plus i've tried handle,application,form1}

Set the Parent property of ed to the component you want to have ed
inside. This is Self (the Form) in most cases, sometimes it is a Panel
or something. Do this setting best directly after creating.

-Michael

Re:REQ: Help creating a edit box at run time sample enclosed plus error received


In article <stouOIrcskMqOZKQznIhMZxXj...@4ax.com>, Karl Ryan

Quote
<K...@Rytec.force9.co.uk> writes:
>EInvalidoperation with message 'CONTROL' has no parent window

>can anyone please tell me how to display my edit box.

That is one of the clearest error messages I have ever seen <g> The Tedit has
no parent window.

Immediately after creating it code :-

 ed.parent := Self; (or whatever control it should be on if its not the form)

You're lucky it tells you. Most of the earlier Delphis just did not display the
control and one was left wondering "where the heck is it".

The Parent of a control is reponsible for passing it the windows messages,
which include things like "Show Yourself" etc.

Look up "Parent" in Delphi help

Alan Lloyd
alangll...@aol.com

Other Threads