Question and Answer Database FAQ4370C.txt :Printing Quick Reports in a thread Category :VCL Platform :Win95/NT Product :C++Builder1.0, C++Builder3.x, C++Builder4.x, Question: When I attempt to pring a Quick report in a thread the application hangs. Is there any way to fix this? Answer: Yes, as it says in the TThread that is generated by the File -> New ... -> Thread Object wizard, Methods and properties in the VCL need to be called using Synchronize(). The following code show how: //--------------------------------------------------------------------------- #include#pragma hdrstop #include "Unit1.h" #include "Unit2.h" #pragma package(smart_init) //--------------------------------------------------------------------------- // Important: Methods and properties of objects in VCL can only be // used in a method called using Synchronize, for example: // // Synchronize(UpdateCaption); // // where UpdateCaption could look like: // // void __fastcall PrintQReport::UpdateCaption() // { // Form1->Caption = "Updated in a thread"; // } //--------------------------------------------------------------------------- __fastcall PrintQReport::PrintQReport(bool CreateSuspended) : TThread(CreateSuspended) { } //--------------------------------------------------------------------------- void __fastcall PrintQReport::Execute() { //---- Place thread code here ---- Synchronize(Print); } //--------------------------------------------------------------------------- void __fastcall PrintQReport::Print() { Form1->QuickRep1->Print(); } //--------------------------------------------------------------------------- 2/11/1999 10:50:10 AM
Last Modified: 01-SEP-99