Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create richtext at runtime, in web app

Status
Not open for further replies.

aberbotimue

Programmer
Oct 23, 2009
4
GB
X-posted - Its stumped me, and another forumds thus far!

Can anyone point me in the right direction..

I am running a very quick cgi web application.. but require a print out as an rtf..

in a stand alone app I drop the richtext componant on, and it does what it needs, and then prints, like i want it to.

in the web app, I have to create it at run time.. so I have


Code:
with TRichedit.Create(self) do
try
  Visible := false;
  lines.loadfromfile('c:\formations\testfile.rtf');
  // Print('Printer');
finally
   Free;
end;

this gives me an error like

Code:
Internal Application Error
 
Control '' has no parent window

after some time with my good freind google, I found loads saying its about allocating an appropriate parent

so I added


Code:
  parent := self;
 
and tried
 
  parent := nil;
 
even tried   

  parent := application.webform;

all giving me compile errors.. as you may have guessed, i am a weekend coder, not doing this day in day out...

can anyopne give me that special line I need!

Cheers all

Aber
 
Thanks Roo

but still gives the

Control 'RichEdit2' has no parent window

error

so I now have

Code:
Fbox := TRichedit.Create(nil) ;
with Fbox do
begin
    Name := 'RichEdit2';
    Parent := nil;
    Left := 208;
    Top := 224;
    Width := 185;
    Height := 89;
    Lines.Clear;
    Lines.Add('RichEdit2');
    TabOrder := 0;
end;

 
If only!!

Thats where I started...

removing the parent gives

Code:
Internal Application Error
Control 'RichEdit2' has no parent window 
c

When you apply parent to the 'TWebModule1' via self, you get

[code]
[DCC Error] codebase.pas(299): E2010 Incompatible types: 'TWinControl' and 'TWebModule1'
[code]

The angle i was pondering was casting the 'TWebModule1' to 'TWinControl'  But wouln't know where to start, or even if one could.

I have achived other visual componants with ease, it just seems to be the RTF componant that required a parent?
 
Delphi's Richedit control is based on microsoft's Richedit control. This control needs a parent window handle to be able to process window messages sent to the control.

I don't know if you can create normal TForms in a web application. IF you can do this then create a Form at runtime with the Richedit on it.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
daddy's right - I'd forgotten about it being parent dependant. Sorry if I misled you.

Roo
Delphi Rules!
 
Daddy, Thanks, I'll have a go at that.. Not as easy, as I am not sure how to create a form, either on the fly!!

Roo.. god no, thanks for the help.. I thought I was just going mad, as I could create other stuff, and not this!! I am genuenly thankfull for your time, for taking the effort to reply..

I'll drop some code back here when I have givven it a try!! and let you know what happened...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top