// netmsg.h: inte***ce for the cnetmsg class.
////
#if !defined(afx_netmsg_h__b5470113_4819_4165_80af_f23918be2d76__included_)
#define afx_netmsg_h__b5470113_4819_4165_80af_f23918be2d76__included_
#if _msc_ver > 1000
#pragma once
#endif // _msc_ver > 1000
class cnetmsg
const unsigned short getsize(void)
char *getbuf(void)
public:
virtual bool create(const char* pbugmsg, dword dwmsgsize);
virtual bool isvalid(void);
virtual void send(void);
virtual void process(void *pinfo);
public:
static int getmaxsize(void)
static unsigned short gettype(const char* pbugmsg,dword dwmsgsize);
static unsigned short getsize(const char* pbugmsg,dword dwmsgsize);
static cnetmsg* createmsg(const char *pbugmsg, dword dwmsgsize);
protected:
union;
};};
//extern cnetwork g_objnetwork;
#endif // !defined(afx_netmsg_h__b5470113_4819_4165_80af_f23918be2d76__included_)\
// netmsg.cpp: implementation of the cnetmsg class.
////
#include "stdafx.h"
#include "test.h"
#include "netmsg.h"
#ifdef _debug
#undef this_file
static char this_file=__file__;
#define new debug_new
#endif
//// construction/destruction
//cnetmsg::cnetmsg()
cnetmsg::~cnetmsg()
void cnetmsg::reset()
bool cnetmsg::isvalid(void)
return true;
}bool cnetmsg::create(const char* pbugmsg, dword dwmsgsize)
if ( 0 == gettype(pbugmsg, dwmsgsize))
memecpy(this->m_bugmsg, pbugmsg, dwmsgsize);
return true;
}void cnetmsg::process(void *pinfo)
unsigned short* punshort = (unsigned short*)pbugmsg;
return punshort[1];
}unsigned short cnetmsg::getsize(const char* pbugmsg,dword dwmsgsize)
return punshort[0] + 8;
cnetmsg* cnetmsg::createmsg(const char *pbugmsg, dword dwmsgsize)
int nsize = cnetmsg::getsize(pbugmsg, dwmsgsize);
if ((int)dwmsgsize != nsize - 8)
cnetmsg *pmsg = null;
int type = cnetmsg::gettype(pbugmsg,dwmsgsize);
switch(type)
if (!pmsg)
return null;
if (!pmsg->create(pbugmsg, dwmsgsize))
return pmsg;
}
MFC對訊息處理的封裝
1 採用mfc的巨集將訊息對映到c 成員函式的方式中以避免產生巨集大的虛函式分配表 2 cwintrhead類成員函式run 的run方法呼叫了getmessage translatemessage dispatchmessage 3 訊息處理幾乎所有的視窗物件使用afxwndproc 視窗處理函式...
MFC對訊息處理的封裝
1 採用mfc的巨集將訊息對映到c 成員函式的方式中以避免產生巨集大的虛函式分配表 2 cwintrhead類成員函式run 的run方法呼叫了getmessage translatemessage dispatchmessage 3 訊息處理幾乎所有的視窗物件使用afxwndproc 視窗處理函式...
DirectUI訊息迴圈的簡單封裝
一.真窗體和假窗體 首先在directwindow內部建立乙個真窗體 基於wtl 可以接收訊息 class cmessagewindow public cwindowimpl cmessagewindow 然後在在handlemessage 處理訊息 二.通過messagedispatcher 訊息...