C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[37336] 쓰래드 질문이욥!!!
이성제 [14dia] 748 읽음    2004-09-19 16:30
그 빌더에서 제공하는 쓰래드를 이용 했는데요

그 쓰래드에서

사용자 정의 함수를 선언하고

폼에 있는 컴포넌트의 이벤트를 연동 하려고 하는데

쓰래드의 명칭을 몰라서 어떻게 해야할지 모르겠네요

::::::::::::::::::::::::::: 유닛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();
}
//---------------------------------------------------------------------------







이렇게 됬습니다.

고수님들의 빠른 답변 기다리고 있겠습니다.

+ -

관련 글 리스트
37336 쓰래드 질문이욥!!! 이성제 748 2004/09/19
37357     Re:쓰래드 질문이욥!!! 최민희 829 2004/09/22
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.