Label caption flimmert
-
Hi
Ich srarte ein download in einem thread:
// Downloading TMemoryStream *mem = new TMemoryStream(); Form1->IdHTTP1->Get(Update_File, mem); mem->SaveToFile(Update_File_NameOnly); delete mem;
Dann übernimmt eventhandler von IdHTTP1 die status auswertung:
void __fastcall TForm1::DownloadStatus(TObject *Sender, TWorkMode AWorkMode, const int AWorkCount) { int ProzentTotal; int Prozent_1; Prozent_1 = Download.Size_Total/100; ProzentTotal = AWorkCount/Prozent_1 ; AnsiString Dummy1 = Format("%0.0n kb", ARRAYOFCONST((float(Download.Size_Total)/1024))); AnsiString Dummy2 = Format("%0.0n Kb", ARRAYOFCONST((float(AWorkCount)/1024))); Form1->Label_Progress->Caption = Dummy2 +"/" + Dummy1 ; Form1->Label_Prozent->Caption = AnsiString(ProzentTotal) + " %"; Form1->ProgressBar1->Position = ProzentTotal; }
Form1->Label_Progress->Caption flimmert dann oder hat ab und zu bold attribut... ich weiss nicht ob das am fehlenden synchronize liegt aber DownloadStatus funktion liegt nicht im thread sondern auf form1 und da gibt es keinen synchronize.
-
hallo Dreamgazer,
um das ganze besser zu machen würde ich die indy-komp komplett in der thread verlagern und über synchronize im mainform nur eine zustands visualisierung machen.
Das ist der bessere und sichere weg.gruß rainer