//CNetClientTestDlg.h : 头文件
static void OnNetMsg(void *pNotifyObj,Packet_mark *pMark, char *Msg, int nMsgLen);
//CNetClientTestDlg.cpp
void CCNetClientTestDlg::OnNetMsg(void *pNotifyObj,Packet_mark *pMark, char *Msg, int nMsgLen)
{
//****方法一
CCNetClientTestDlg *pNetClientDlg = (CCNetClientTestDlg *)pNotifyObj; //***注意:pNotifyObj 传入的必须是CCNetClientTestDlg类
pNetClientDlg->GetDlgItem(IDC_STATIC)->SetWindowTextW(_T("OKK"));
//******方法二 全局函数
theApp.SetValue();
/*int a=1+1;*/
}
//*****全局函数定义
//****CNetClientTest.h : PROJECT_NAME 应用程序的主头文件
class CCNetClientTestApp : public CWinApp
{
public:
CCNetClientTestApp();
// 重写
public:
virtual BOOL InitInstance();
// 实现
void SetValue();
DECLARE_MESSAGE_MAP()
};
extern CCNetClientTestApp theApp;
//CNetClientTest.cpp : 定义应用程序的类行为
void CCNetClientTestApp::SetValue()
{
CCNetClientTestDlg lg;
/*lg.GetDlgItem(IDC_STATIC)->SetWindowTextW(_T("这是全局变量"));*/ //error
/*lg.SendMessage(WM_MYMESSAGE,0,0); error*/
CWnd *ppWnd=CWnd::FindWindowW(NULL,_T("CNetClientTest")); //CNetClientTest是窗体Caption名称
/*ppWnd->SendMessage(WM_MYMESSAGE,0,0);*/
ppWnd->GetDlgItem(IDC_STATIC)->SetWindowTextW(_T("这是全局变量"));
}