Stringizing Operator (#)
The number-sign or “stringizing” operator (#) converts macro parameters (after expansion) to string constants. It is used only with macros that take arguments. If it precedes a formal parameter in the macro definition, the actual argument passed by the macro invocation is enclosed in quotation s and treated as a string literal. The string literal then replaces each occurrence of a combination of the stringizing operator and formal parameter within the macro definition.

解决方案 »

  1.   

    我要输入的可能是WM_CREATE, 也可能是整数1, 也可能是值为1的变量, 但是最后都返回"WM_CRAETE"
    是不是只能把所有情况都加进去再判断
      

  2.   

    #define STRING(str) #str
    AfxMessageBox(CString(STRING(WM_CREATE)));
      

  3.   


    这个我知道, 但是我想要的是这样的:LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
            STRING(message);//这个STRING要怎么写
            ..........
    }
      

  4.   

    if( input == WM_CREATE )
    return "WM_CREATE";
      

  5.   

    LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    #define __CASE(x) case x: OutputDebugStringA(#x); break;
        __CASE(WM_CREATE);
        __CASE(WM_PAINT);
        __CASE(WM_CLOSE);
        __CASE(WM_DESTROY);
    #undef __CASE
    }
      

  6.   

    看来是最简单的只有这样了, 不过还要加switch吧
      

  7.   

    vc6 安装盘 中 有个 SPY 工程, 其中 有 个 WM.C ,里面就有 所有 WM 转 “WM” 的 代码。
      

  8.   

    看来是最简单的只有这样了, 不过还要加switch吧
    写的太简略,给忘了。一个数字怎么可能没有任何依据转换为字符串?实际上,除了一一映射确实没有什么好方法。