//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("这是全局变量"));
}

 

相关文章:

  • 2021-04-03
  • 2021-06-19
  • 2022-12-23
  • 2021-12-22
  • 2022-03-09
  • 2022-12-23
  • 2022-03-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-17
  • 2021-12-18
  • 2021-12-18
  • 2021-07-30
  • 2022-12-23
相关资源
相似解决方案