如题:
// _AFX_FUNCNAME definition
#ifdef UNICODE
#define _AFX_FUNCNAME(_Name) _Name##W
#else
#define _AFX_FUNCNAME(_Name) _Name##A
#endif请问下这个具体怎么用的。 功能是啥?请帮忙解释下如下CWnd中的 _AFX_FUNCNAME的用途。谢谢
#pragma push_macro("MessageBox")
#undef MessageBox
int _AFX_FUNCNAME(MessageBox)(LPCTSTR lpszText, LPCTSTR lpszCaption = NULL,
UINT nType = MB_OK);
int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption = NULL,
UINT nType = MB_OK);
#pragma pop_macro("MessageBox")

解决方案 »

  1.   

    为了能同时对应Unicode和ANSI,调用不同的API
    代码中写的MessageBox,通过这个宏,在Unicode下变成MessageBoxW,否则是MessageBoxA
      

  2.   

    理解了宏函数_AFX_FUNCNAME的定义 后续的代码就好理解了
     #ifdef UNICODE
    #define _AFX_FUNCNAME(_Name) _Name##W
    #else
    #define _AFX_FUNCNAME(_Name) _Name##A
    #endif预编译期间,如果定义了宏UNICODE 宏 则 执行代码
     _Name加W否则加A
    具体到
    int _AFX_FUNCNAME(MessageBox)(LPCTSTR lpszText, LPCTSTR lpszCaption = NULL,
    UINT nType = MB_OK);
     就是如果定义了宏 UNICODE
      则上句变为 MessageBoxW 否则 MessageBoxA