Skip to content
Snippets Groups Projects
Commit 42155ed2 authored by rswindell's avatar rswindell
Browse files

Added a StatusBar, Timer, and List.

parent c939b0fb
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,9 @@
#include <QControls.hpp>
#include <QStdCtrls.hpp>
#include <QForms.hpp>
#include <QComCtrls.hpp>
#include <QExtCtrls.hpp>
#include <QTypes.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
......@@ -16,10 +19,14 @@ __published: // IDE-managed Components
TButton *CreateButton;
TButton *KillButton;
TMemo *Log;
TStatusBar *StatusBar;
TTimer *Timer;
void __fastcall CreateButtonClick(TObject *Sender);
void __fastcall KillButtonClick(TObject *Sender);
void __fastcall TimerTick(TObject *Sender);
private: // User declarations
public: // User declarations
TList* List;
TCriticalSection* CriticalSection;
__fastcall TForm1(TComponent* Owner);
};
......
......@@ -2,8 +2,8 @@ object Form1: TForm1
Left = 536
Top = 314
Width = 211
Height = 283
VertScrollBar.Range = 273
Height = 303
VertScrollBar.Range = 292
HorzScrollBar.Range = 203
ActiveControl = ListBox
Caption = 'Form1'
......@@ -45,4 +45,17 @@ object Form1: TForm1
ScrollBars = ssAutoBoth
TabOrder = 3
end
object StatusBar: TStatusBar
Left = 0
Top = 284
Width = 211
Height = 19
Panels = <>
SimplePanel = True
end
object Timer: TTimer
OnTimer = TimerTick
Left = 96
Top = 144
end
end
......@@ -25,14 +25,19 @@ __fastcall TMyThread::TMyThread(bool CreateSuspended)
: TThread(CreateSuspended)
{
}
void __fastcall TMyThread::AddToLog()
{
Log->Lines->Add(ThreadID);
}
//---------------------------------------------------------------------------
void __fastcall TMyThread::Execute()
{
while(!Terminated) {
CriticalSection->Enter();
Log->Lines->Add(ThreadID);
Synchronize(AddToLog);
CriticalSection->Enter();
List->Add(new AnsiString(ThreadID));
CriticalSection->Leave();
Sleep(1000);
Sleep(1);
}
}
//---------------------------------------------------------------------------
......@@ -14,8 +14,10 @@ protected:
void __fastcall Execute();
public:
TMemo* Log;
TList* List;
TCriticalSection* CriticalSection;
__fastcall TMyThread(bool CreateSuspended);
void __fastcall AddToLog(void);
};
//---------------------------------------------------------------------------
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment