• MFC 静态函数处理


    //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("这是全局变量"));
    }
  • 相关阅读:
    常用正则表达式
    玉洁哥的设计模式指摘
    jquery makearray()使用
    html/css技巧总结
    json 数组 对象 xml 之间转换(待补充)
    Html5 Geolocation获取地理位置信息
    JSON.stringify 应用
    url操作一网打尽(一)
    jquery选择器
    JavaScript Window Location
  • 原文地址:https://www.cnblogs.com/marky/p/3833863.html
Copyright © 2020-2023  润新知