|
그 빌더에서 제공하는 쓰래드를 이용 했는데요
그 쓰래드에서
사용자 정의 함수를 선언하고
폼에 있는 컴포넌트의 이벤트를 연동 하려고 하는데
쓰래드의 명칭을 몰라서 어떻게 해야할지 모르겠네요
::::::::::::::::::::::::::: 유닛1(폼)의 해더 :::::::::::::::::::::::::::
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ScktComp.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TServerSocket *ServerSocket1;
void __fastcall FormShow(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
::::::::::::::::::::::::::: 유닛1(폼)의 소스:::::::::::::::::::::::::::
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
ServerSocket1->OnClientRead=????????; // 여기서 ?????????에 들어갈 소스를 모르겠습니다.
}
//---------------------------------------------------------------------------
::::::::::::::::::::::::::: 쓰래드의 해더:::::::::::::::::::::::::::
//---------------------------------------------------------------------------
#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include <Classes.hpp>
//---------------------------------------------------------------------------
class TR : public TThread
{
private:
protected:
void __fastcall Execute();
public:
__fastcall TR(bool CreateSuspended);
__fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
};
//---------------------------------------------------------------------------
#endif
::::::::::::::::::::::::::: 쓰래드의 소스:::::::::::::::::::::::::::
//---------------------------------------------------------------------------
#include <vcl.h>
#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 TR::UpdateCaption()
// {
// Form1->Caption = "Updated in a thread";
// }
//---------------------------------------------------------------------------
__fastcall TR::TR(bool CreateSuspended)
: TThread(CreateSuspended)
{
}
//---------------------------------------------------------------------------
void __fastcall TR::Execute()
{
//---- Place thread code here ----
}
//---------------------------------------------------------------------------
__fastcall TForm1::ServerSocket1ClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
AnsiString ReceiveText = Socket->ReceiveText();
}
//---------------------------------------------------------------------------
이렇게 됬습니다.
고수님들의 빠른 답변 기다리고 있겠습니다.
|