?? gserver.h
字號:
//---------------------------------------------------------------------------
#ifndef GServerH
#define GServerH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <StdCtrls.hpp>
#include <winsock.h>
#include "datastr.h"
#define WM_CHATSERVER WM_USER+0X112
#define LINAME 0
#define LIIP 1
#define LISTATUS 2
#define LIRBYTES 3
#define LISBYTES 4
unsigned long LocalIp()
{
char szipTemp[512];
unsigned long ip;
hostent *host;
if(gethostname(szipTemp,511)==SOCKET_ERROR)return INADDR_NONE;
host=gethostbyname(szipTemp);
if(host==NULL)return INADDR_NONE;
ip=*((unsigned long*)host->h_addr_list[0]);
return ip;
}
//---------------------------------------------------------------------------
class PACKAGE GServer : public TMemo
{
private:
char*tBuffer,*SRBuffer,*szTemp,*tempBuffer;
int tBufferSize,RBufferSize,zeroInt,dhSize;
TListView *lv;
PGSU gsu;
PDATAHEADER pdh;
char*pdhchar;
int id,maxChaters;
SOCKET sk;
bool bListen,bDoorClose;
BOOL bImidiate;
char CloseRefuse;
void __fastcall HandleChat(TMessage&);
bool Comfirm(PPINFO,int index);
TNotifyEvent FOnConnecting,FOnLeave,FOnDisConnect;
void __fastcall SetImidiate(BOOL);
void Send(int index);
void SendAll(int);
bool AddBuffer(int,int);
void LeaveAll();
bool Read(SOCKET);
bool Accept(SOCKET);
int indexBySocket(SOCKET);
int indexByID(int tid);
void Leave(int index);
int Chaters();//bool beListen();
/*inline void LineAdd(int a,char*b)
{Lines->Insert(a,b);
Perform(WM_VSCROLL,SB_TOP,0);}*/
protected:
public:
__fastcall GServer(TComponent* Owner);
unsigned short Port;
AnsiString Password,WelcomMessage;
bool Listen();
void DisConnect();
void ListInfo();
void Kick(int);
__published:
__property TListView *ClientList={read=lv,write=lv};//lv的COLUMNS:呢稱,ID,IP
__property bool beListen={read=bListen};
__property bool DoorClose={read=bDoorClose,write=bDoorClose};
__property BOOL Imidiate={read=bImidiate,write=SetImidiate};
__property TNotifyEvent OnConnecting={read=FOnConnecting,write=FOnConnecting};
__property TNotifyEvent OnLeave={read=FOnLeave,write=FOnLeave};
__property TNotifyEvent OnDisConnect={read=FOnDisConnect,write=FOnDisConnect};
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_CHATSERVER,TMessage,HandleChat);
END_MESSAGE_MAP(TMemo);
};
//---------------------------------------------------------------------------
#endif
/*#include "cmdDefine.h"
#define WM_CHATSERVER WM_USER+0x101
class GServer:public TRichEdit
{
_published:
public:
private:
//bool LineAdd(char*);
};*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -