I have a program for semester pass and have a problem. It reads text into a TStringList
then operates on it in a TMemo
. Everything is OK when compiling. But when I run the EXE file without Borland installed, it hangs when doing anything else than just this program, for example running a browser on top of it. It happens only with big files like 3000 lines. How can I solve this?
[reconstructed Form source by Spektre]
unit1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#include <stdio.h>
#include <strutils.hpp>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
AnsiString NazwaPliku;
AnsiString szerstop;
AnsiString dlustop;
AnsiString final;
AnsiString Linia;
AnsiString Linia1;
TStringList *Lista=NULL;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner):TForm(Owner)
{
Lista = new TStringList;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Wczytaj1Click(TObject *Sender)
{
if(OpenDialog1->Execute())
{
Lista->LoadFromFile(OpenDialog1->FileName);
NazwaPliku=OpenDialog1->FileName;
Memo1->Lines->LoadFromFile(NazwaPliku);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Zamknij1Click(TObject *Sender)
{
if (Application->MessageBox("Czy na pewno zakończyć?","Tak",MB_YESNO|MB_ICONQUESTION)==IDYES)
{
Application->Terminate();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Konwertuje1Click(TObject *Sender)
{
AnsiString Poczatek="<?xml version=\"1.0\" encoding=\"UTF-8\"?><kml xmlns=\"http://www.opengis.net/kml/2.2\"><Document><name>Ścieżka</name><description>.</description><Style id=\"yellowLineGreenPoly\"><LineStyle><color>7f00ffff</color><width>75</width></LineStyle><PolyStyle><color>7f00ff00</color></PolyStyle></Style><Placemark><name>Absolute Extruded</name><description>.</description><styleUrl>#yellowLineGreenPoly</styleUrl><LineString><extrude>1</extrude><tessellate>1</tessellate><altitudeMode>absolute</altitudeMode><coordinates>";
AnsiString Koniec="</coordinates></LineString></Placemark></Document></kml>";
Memo1->Clear();
Memo1->Lines->Add(Poczatek);
for(int i=0; i<Lista->Count; i++)
{
AnsiString str_linia=Lista->Strings[i];
char* linia=str_linia.c_str();
if(strstr(linia,"GPGGA")!=NULL)
{
int stopnies, stopnied, lpz;
double czas, minutys, minutyd, szer_stop, dlu_stop;
char ms, md;
lpz=sscanf(linia, "$GPGGA,%lf,%2d%lf,%c,%3d%lf,%c", &czas, &stopnies, &minutys, &ms, &stopnied, &minutyd, &md);
Sleep(0);
if(lpz==7)
{
if(ms=='N') szer_stop=stopnies+(minutys/60.0);
else szer_stop=-(stopnies+(minutys/60.0));
if(md=='E') dlu_stop=stopnied+(minutyd/60.0);
else dlu_stop=-(stopnied+(minutyd/60.0));
}
Edit1->Text=FloatToStr(szer_stop);
Edit1->Refresh();
Edit2->Text=FloatToStr(dlu_stop);
Edit2->Refresh();
}
AnsiString szerstop=Edit1->Text;
szerstop=StringReplace(szerstop,",",".",TReplaceFlags());
AnsiString dlustop=Edit2->Text;
dlustop=StringReplace(dlustop,",",".",TReplaceFlags());
AnsiString final=dlustop+","+szerstop;
Memo1->Lines->Add(final);
}
Memo1->Lines->Add(Koniec);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Wyczysc1Click(TObject *Sender)
{
Memo1->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Zapiszjako1Click(TObject *Sender)
{
SaveDialog1->Execute();
Memo1->Lines->SaveToFile(SaveDialog1->FileName);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
if(Application->MessageBox("Czy na pewno zakończyć?","Tak",MB_YESNO | MB_ICONQUESTION)==IDNO)
{
Action=caNone;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Czcionka1Click(TObject *Sender)
{
if (FontDialog1->Execute());
{
Memo1->Font->Name=FontDialog1->Font->Name;
Memo1->Font->Color=FontDialog1->Font->Color;
Memo1->Font->Size=FontDialog1->Font->Size;
Memo1->Font->Style=FontDialog1->Font->Style;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Info1Click(TObject *Sender)
{
ShowMessage("");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Filtruj1Click(TObject *Sender)
{
Memo1->Clear();
AnsiString Linia1;
{
for(int j=0; j<Lista->Count;j++)
{
AnsiString str_linia1=Lista->Strings[j];
char* linia1=str_linia1.c_str();
if(strstr(linia1,"GPGGA")!=NULL)
Memo1->Lines->Add(linia1);
Sleep(0);
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PrzywrcTXT1Click(TObject *Sender)
{
Memo1->Clear();
Memo1->Lines->LoadFromFile(NazwaPliku);
}
//---------------------------------------------------------------------------
unit1.h
//$$---- Form HDR ----
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Dialogs.hpp>
#include <Buttons.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TMemo *Memo1;
TOpenDialog *OpenDialog1;
TPanel *Panel1;
TSpeedButton *Wczytaj1;
TSpeedButton *Zamknij1;
TSpeedButton *Konwertuje1;
TEdit *Edit1;
TSaveDialog *SaveDialog1;
TEdit *Edit2;
TSpeedButton *Wyczysc1;
TSpeedButton *Zapiszjako1;
TFontDialog *FontDialog1;
TSpeedButton *Czcionka1;
TSpeedButton *Info1;
TSpeedButton *Filtruj1;
TSpeedButton *PrzywrcTXT1;
void __fastcall Wczytaj1Click(TObject *Sender);
void __fastcall Zamknij1Click(TObject *Sender);
void __fastcall Konwertuje1Click(TObject *Sender);
void __fastcall Wyczysc1Click(TObject *Sender);
void __fastcall Zapiszjako1Click(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall Czcionka1Click(TObject *Sender);
void __fastcall Info1Click(TObject *Sender);
void __fastcall Filtruj1Click(TObject *Sender);
void __fastcall PrzywrcTXT1Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
void __fastcall TForm1::Idleloop(TObject *Sender, bool &Done);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
unit1.dfm
object Form1: TForm1
Left = 0
Top = 0
ClientHeight = 362
ClientWidth = 619
Color = clBtnFace
Font.Charset = OEM_CHARSET
Font.Color = clWindowText
Font.Height = 14
Font.Name = 'System'
Font.Pitch = fpFixed
Font.Style = [fsBold]
OldCreateOrder = False
OnClose = FormClose
PixelsPerInch = 96
TextHeight = 14
object Memo1: TMemo
Left = 0
Top = 31
Width = 619
Height = 331
Align = alClient
ScrollBars = ssBoth
TabOrder = 0
ExplicitTop = 32
end
object Panel1: TPanel
Left = 0
Top = 0
Width = 619
Height = 31
Align = alTop
TabOrder = 1
object Wczytaj1: TSpeedButton
Left = 34
Top = 4
Width = 23
Height = 22
Glyph.Data = {
F6000000424DF600000000000000760000002800000010000000100000000100
04000000000080000000CE0E0000C40E00001000000000000000000000000000
80000080000000808000800000008000800080800000C0C0C000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
77777777777777777777000000000007777700333333333077770B0333333333
07770FB03333333330770BFB0333333333070FBFB000000000000BFBFBFBFB07
77770FBFBFBFBF0777770BFB0000000777777000777777770007777777777777
7007777777770777070777777777700077777777777777777777}
OnClick = Wczytaj1Click
end
object Zamknij1: TSpeedButton
Left = 232
Top = 4
Width = 23
Height = 22
Glyph.Data = {
6E040000424D6E04000000000000360000002800000013000000120000000100
18000000000038040000CE0E0000D80E00000000000000000000C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000FF
FFFFC0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0C0C0C0000000FFFFFF
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0000000000000000000FFFFFFC0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000FFFFFFC0C0C0C0C0C0C0C0C0
C0C0C0000000C0C0C0C0C0C0C0C0C0000000000000000000FFFFFFC0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0000000FFFFFFC0C0C0C0C0C0C0C0C0C0C0C0C0C0C000
0000C0C0C0C0C0C0C0C0C0C0C0C0000000000000000000FFFFFFC0C0C0C0C0C0
C0C0C0000000000000FFFFFFC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0000000000000000000FFFFFFC0C0C000000000
0000FFFFFFC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0000000000000000000000000000000FFFFFFC0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0000000000000000000FFFFFFC0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0000000000000000000000000000000FFFFFFC0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000
000000000000FFFFFFC0C0C0000000FFFFFFC0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0000000000000000000000000FF
FFFFC0C0C0C0C0C0C0C0C0000000000000FFFFFFC0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0000000C0C0C0C0C0C0000000000000000000000000FFFFFFC0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0000000000000FFFFFFC0C0C0C0C0C0C0C0C0C0C0C000
0000C0C0C0C0C0C0000000000000FFFFFFC0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0000000000000FFFFFFC0C0C0C0C0C0C0C0C0000000C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000}
OnClick = Zamknij1Click
end
object Konwertuje1: TSpeedButton
Left = 92
Top = 4
Width = 23
Height = 22
Glyph.Data = {
6E040000424D6E04000000000000360000002800000013000000120000000100
18000000000038040000C40E0000C40E00000000000000000000C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0000000000000000000000000000000
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C00000000000000000000000000000
00000000C0C0C0000000C0C0C0000000FFFFFFFFFFFFFFFFFF000000C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000757575FFFFFFFFFFFFFFFFFF000000
C0C0C0000000C0C0C0000000000000000000000000000000C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0000000757575757575757575757575000000C0C0C000
0000C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0
C0C0C0C0C0C0000000757575757575757575757575000000C0C0C00000000000
00000000000000000000000000C0C0C0C0C0C0C0C0C0000000000000C0C0C0C0
C0C0000000757575757575757575757575000000C0C0C0000000000000FFFFFF
FFFFFFFFFFFF000000C0C0C0000000000000000000000000000000C0C0C00000
00FFFFFFFFFFFFFFFFFF757575000000C0C0C000000000000000000000000000
0000000000C0C0C0000000000000000000000000000000C0C0C0000000757575
757575757575757575000000C0C0C0000000C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0000000000000C0C0C0C0C0C000000075757575757575
7575757575000000C0C0C0000000000000000000000000000000000000000000
C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C00000007575757575757575757575
75000000C0C0C0000000000000FFFFFFFFFFFFFFFFFFFFFFFF000000C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000FFFFFFFFFFFFFFFFFFFFFFFF000000
C0C0C0000000000000FFFFFFFFFFFFFFFFFFFFFFFF000000C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0000000FFFFFFFFFFFFFFFFFFFFFFFF000000C0C0C000
0000000000FFFFFFFFFFFFFFFFFFFFFFFF000000C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0000000FFFFFFFFFFFFFFFFFFFFFFFF000000C0C0C00000000000
00000000000000000000000000000000C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0000000000000000000000000000000000000C0C0C0000000C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0
C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000}
OnClick = Konwertuje1Click
end
object Wyczysc1: TSpeedButton
Left = 150
Top = 4
Width = 23
Height = 22
Glyph.Data = {
0E060000424D0E06000000000000360000002800000016000000160000000100
180000000000D805000000000000000000000000000000000000C8D0D4C8D0D4
C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0
D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D40000C8D0
D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8
D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4
0000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4
C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0
D4C8D0D40000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0
D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8
D0D4C8D0D4C8D0D40000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8
D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4
C8D0D4C8D0D4C8D0D4C8D0D40000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4
C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0
D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D40000C8D0D4C8D0D4C8D0D4C8D0D40000
00000000000000000000000000000000000000C8D0D4C8D0D4C8D0D4C8D0D4C8
D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D40000C8D0D4C8D0D4C8D0D400
0000C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0000000000000C8D0D4C8D0D4
C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D40000C8D0D4C8D0D4
C8D0D4000000C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C000000000BFBF0000
00C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D40000C8D0
D4C8D0D4C8D0D4000000C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C000000000
BFBF00BFBF000000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4
0000C8D0D4C8D0D4C8D0D4C8D0D4000000FFFFFF00FFFFFFFFFF00FFFFFFFFFF
00FFFF00000000BFBF00BFBF000000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0
D4C8D0D40000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4000000FFFFFF00FFFFFFFF
FF00FFFFFFFFFF00FFFF00000000BFBF00BFBF000000C8D0D4C8D0D4C8D0D4C8
D0D4C8D0D4C8D0D40000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4000000FF
FFFF00FFFFFFFFFF00FFFFFFFFFF00FFFF00000000BFBF00BFBF000000C8D0D4
C8D0D4C8D0D4C8D0D4C8D0D40000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4
C8D0D4000000FFFFFF00FFFFFFFFFF00FFFFFFFFFF00FFFF00000000BFBF0000
00C8D0D4C8D0D4C8D0D4C8D0D4C8D0D40000C8D0D4C8D0D4C8D0D4C8D0D4C8D0
D4C8D0D4C8D0D4C8D0D4000000FFFFFF00FFFFFFFFFF00FFFFFFFFFF00FFFF00
0000000000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D40000C8D0D4C8D0D4C8D0D4C8
D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4000000FFFFFF00FFFFFFFFFF00FFFF
FFFFFF00FFFF000000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D40000C8D0D4C8D0D4
C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D40000000000000000
00000000000000000000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D40000C8D0
D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8
D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4
0000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4
C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0
D4C8D0D40000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0
D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8
D0D4C8D0D4C8D0D40000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8
D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4
C8D0D4C8D0D4C8D0D4C8D0D40000C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4
C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0
D4C8D0D4C8D0D4C8D0D4C8D0D4C8D0D40000}
OnClick = Wyczysc1Click
end
object Zapiszjako1: TSpeedButton
Left = 59
Top = 4
Width = 23
Height = 22
Glyph.Data = {
F6000000424DF600000000000000760000002800000010000000100000000100
04000000000080000000C40E0000C40E00001000000000000000000000000000
8000008000000080800080000000800080008080000080808000C0C0C0000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00888888888888
888888000000000000088044000FF0000408804400F99F000408804400F99F00
04088044000FF0000408804444F99F444408804400F99F004408804088F999F8
040880408F8F999F04088040F9F8F99F04088040F99F999F04088040F99999F8
000880408F999F880808800000FFF00000088888888888888888}
OnClick = Zapiszjako1Click
end
object Czcionka1: TSpeedButton
Left = 175
Top = 4
Width = 23
Height = 22
Caption = 'A'
Font.Charset = OEM_CHARSET
Font.Color = clWindowText
Font.Height = -21
Font.Name = 'System'
Font.Pitch = fpFixed
Font.Style = [fsBold]
ParentFont = False
OnClick = Czcionka1Click
end
object Info1: TSpeedButton
Left = 200
Top = 4
Width = 23
Height = 22
Caption = 'i'
Font.Charset = OEM_CHARSET
Font.Color = clWindowText
Font.Height = -21
Font.Name = 'System'
Font.Pitch = fpFixed
Font.Style = [fsBold]
ParentFont = False
OnClick = Info1Click
end
object Filtruj1: TSpeedButton
Left = 118
Top = 4
Width = 23
Height = 22
OnClick = Filtruj1Click
end
object PrzywrcTXT1: TSpeedButton
Left = 4
Top = 4
Width = 23
Height = 22
Glyph.Data = {
F6000000424DF600000000000000760000002800000010000000100000000100
04000000000080000000CE0E0000C40E00001000000000000000000000000000
80000080000000808000800000008000800080800000C0C0C000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
77777777777777777777000000000007777700333333333077770B0333333333
07770FB03333333330770BFB0333333333070FBFB000000000000BFBFBFBFB07
77770FBFBFBFBF0777770BFB0000000777777000777777770007777777777777
7007777777770777070777777777700077777777777777777777}
OnClick = PrzywrcTXT1Click
end
object Edit1: TEdit
Left = 268
Top = 4
Width = 80
Height = 22
TabOrder = 0
Text = 'Edit1'
end
object Edit2: TEdit
Left = 354
Top = 4
Width = 80
Height = 22
TabOrder = 1
Text = 'Edit2'
end
end
object OpenDialog1: TOpenDialog
Left = 440
end
object SaveDialog1: TSaveDialog
Left = 472
end
object FontDialog1: TFontDialog
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
Left = 504
end
end
The simplest will be:
Remove all Sleep()
s
Add Application->ProcessMessages()
into working loop (once for every n-th
iteration)
Add lock
to any operations while you are still doing any stuff
to avoid multiple things to run at a time. You can do this by set Enabled=false;
before execution and Enabled=true;
after, for any button that would conflict your operation. You can put all the buttons on single Panel and enable/disable the panel instead (or even make it invisible).
Threads would be ideal for this but if you got no experience with them it will be hard to implement and debug so I do not recommend to go this way. There is also the OnIdleEvent
which runs when no operations is done in VCL. You could move your computations there but you need to throttle it by time so divide the operation so it works for a while then return to VCL and after that again can continue ...
You can optimize your code for example it is usually faster to accumulate text into AnsiString
and then add it as whole instead of adding to TMemo
line by line for example:
AnsiString txt="";
txt+="123\r\n";
txt+="456\r\n";
txt+="789\r\n";
Memo1->Lines->Add(txt);
Also If I see it right you are doing to many string copying for my taste ...
Why are you using Edit1,Edit2
as temp variable? That is SLOOW as any change in Edit1->Text
will invoke repaint and stuff ... Why not use some AnsiString instead and fill the Edit1->Text
after loop ...