Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 10-08-2009, 01:45 PM
aberbotimue aberbotimue is offline
Junior Member
 
Join Date: Oct 2009
Posts: 8
Question create richtext at runtime, in web app

Hi all...

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
Reply With Quote
  #2  
Old 10-20-2009, 02:54 PM
aberbotimue aberbotimue is offline
Junior Member
 
Join Date: Oct 2009
Posts: 8
Default Still stuck on this one..

I have moved to some of the other code else where, but I have to come back to this one.. any one got any ideas?

its basicly creating a visual comonant on a non visual form I think.. as there isn't a parent window?
Reply With Quote
  #3  
Old 10-20-2009, 06:27 PM
nester261 nester261 is offline
Moderator
 
Join Date: Jan 2004
Location: UK
Posts: 618
Default

Create it something like this:

Code:
var
  RichEdit1: TRichEdit;
begin
  RichEdit1 := TRichEdit.Create(Self);
  with RichEdit1 do
  begin
    Name := 'RichEdit1';
    Parent := Self;
    Left := 208;
    Top := 224;
    Width := 185;
    Height := 89;
    Lines.Clear;
    Lines.Add('RichEdit1');
    TabOrder := 0;
  end;
end;
__________________
"Where there's a will, there's always a way."

-- The Hon Robert Nester Marley O.M. - aka Bob Marley!
Reply With Quote
  #4  
Old 10-21-2009, 10:35 PM
aberbotimue aberbotimue is offline
Junior Member
 
Join Date: Oct 2009
Posts: 8
Default Tried that one!

Thanks for the reply.. Thats one of the versiuons I already tried..

Although, I killed the function, and built it again, setting all the properties you sugest, but get the original issue using "self"

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

I am doing it from within a webmodule, and that seems to be my issue..

Any thoughts?
Reply With Quote
  #5  
Old 10-22-2009, 01:57 AM
nester261 nester261 is offline
Moderator
 
Join Date: Jan 2004
Location: UK
Posts: 618
Default

OK - never actually used a TWebModule in Delphi before as never had the need.

I tried the code from a WebModule and yes it does give the Incompatible Types message but if you change the Parent := Self to Nil then it should be ok, and actually compiled fine for me.

I see though that you say you have tried using nil as the parent? What Error message/s did you receive?
__________________
"Where there's a will, there's always a way."

-- The Hon Robert Nester Marley O.M. - aka Bob Marley!
Reply With Quote
  #6  
Old 10-22-2009, 01:37 PM
aberbotimue aberbotimue is offline
Junior Member
 
Join Date: Oct 2009
Posts: 8
Default Cast the webmodual to 'TWinControl' somhow?

As you say, compiles, but when you then create the componant, without a parent, you get a runtime error of

Code:
 
Internal Application Error

Control '' has no parent window
seems to imply that the componant requires a parent to live!! I was pondering if one could Cast the webmodual to 'TWinControl' somhow? but wouln't know how to do that?
Reply With Quote
  #7  
Old 10-22-2009, 03:29 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,059
Default

You don't really need a richedit to print an rtf file. Please see:

http://www.swissdelphicenter.ch/en/showcode.php?id=1466
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #8  
Old 10-22-2009, 04:01 PM
aberbotimue aberbotimue is offline
Junior Member
 
Join Date: Oct 2009
Posts: 8
Default Need to alter the text in code...

I see the method, but I am constructing some of the main parts of the rtf from within the code too.. if i understand this code, its printing the rtf, externaly to the code, so much harder to alter the file, and to print it..

but definatly a good fall back, if i can't crack this componant issue...
Reply With Quote
  #9  
Old 10-22-2009, 05:20 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,059
Default

You can manipulate the file using TStringlist and then save it back and then print it.

Code:
var
          oSL : TStringlist;
begin
          oSL := TStringlist.Create;
          oSL.LoadFromFile('C:\Thefile.rtf');

          //Do anything here with the file.

          oSL.SaveToFile('C:\Thefile.rtf');//To the same file or any new file.
          oSL.Free;


          //Then here try to print it.
__________________
Regards,
Abdulaziz Jasser
Reply With Quote
  #10  
Old 10-23-2009, 05:15 PM
aberbotimue aberbotimue is offline
Junior Member
 
Join Date: Oct 2009
Posts: 8
Default

I hear what you are saying, and again as a fall back.. but if a few people are doing the tarnsaction at a time, I now need to manage multiple text files on the disk, where creating the rtf dynamicly, means its all managed within the web modual..

this route is more complex to print, uses files so have to manage names etc..

That all said, its getting too close to having to go another route, as this creating an rtf on the fly is turning out to be a mare - no one can help..
Reply With Quote
Reply

Tags
create, dynamic, richtext, runtime, twebmodule

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 09:28 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.