Print report using fastreport4(VCL version)in BCB

edited 8:11PM in FastReport 4.0
Hello ,
in BCB,I create a service application MyService1 on whose event:ServiceExecute a thread is created and resume.
In the thread's cpp file ,I write the following code:

in TService1.cpp:
TThreadPrint *th;
void __fastcall TService1::ServiceExecute(TService *Sender)
{

CoInitialize(NULL) ;
while(!Terminated)
{
if(th==NULL)
{//create a thread if is null
th=new TThreadPrint(true);
th->Resume();
}

Sleep(5000);
}
CoUninitialize();
}

in TThreadPrint.cpp
//
void __fastcall TThreadPrint::Execute()
{
//---- Place thread code here ----
Synchronize(Print);
}
//

void __fastcall TThreadPrint::Print()
{
TfrxReport *frxReport1=new TfrxReport(NULL);
frxReport1->EngineOptions->EnableThreadSafe=true;
frxReport1->EngineOptions->DestroyForms=false;

frxReport1->LoadFromFile("test.fr3");
frxReport1->PrepareReport(true);
frxReport1->PrintOptions->ShowDialog=false;
frxReport1->Print();
}
//
The content of file "test.fr3" is just a string "HELLO".
When the service application MyService1 starts ,then thread TThreadprint will be created and TThreadPrint::Print method executed.
However,in the method TThreadPrint::Print(), the statement frxReport1->Print() executed and quickly finished but without any result what is expected to print the report in the physical printer but the printer does not respon.

Is there any options should be set to make the TfrxReport run effectivily in the thread in the service application.
thx.

Comments

  • edited 8:11PM
    I have exactly the same problem:
    frxReport1->Print() does not work with a TService application.
    Did you find a solution yet?
    yours,
    Herwig

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.