我打印过,ATLTRACE输出宽字符串有问题。怎么办?宽字符串怎么打印到调试输出窗口中?

解决方案 »

  1.   

    先用W2A转换成多字节
    AtlBase.hUSES_CONVERSION;LPCSTR x = W2A(lpsz);
      

  2.   

    为什么我这段代码执行不下去,报异常了。求助
    m_ToolTip.UpdateTipText(nItemID, m_hWnd);
    CRect rc;
    UINT nPos =0, nItemCount = menu.GetMenuItemCount();
    // Get Item Position
    for (; nPos < nItemCount; nPos++)
    {
    if (menu.GetMenuItemID(nPos) == nItemID)
    {
    break;
    }
    }
    int nRes = menu.GetMenuItemRect(NULL, nPos, &rc);
    ATLTRACE("GetMenuItemRect() return %d \nMenu item coordinate(right,top):(%d,%d)\n", nRes, rc.right, rc.top);
    CRect rcTip;
    CToolInfo toolInfo(TTF_TRACK, m_hWnd);
    m_ToolTip.GetToolInfo(&toolInfo); m_ToolTip.GetWindowRect(&rcTip);
    rcTip.MoveToXY(rc.right + 5, rc.top); m_ToolTip.TrackActivate(&toolInfo, TRUE);
    m_ToolTip.MoveWindow(&rcTip);
    OutputDebugString(toolInfo.lpsztext);
      

  3.   

    m_ToolTip.MoveWindow(&rcTip);
    OutputDebugString(toolInfo.lpsztext);
    前一句MoveWindow异常了。
      

  4.   

    一般显示中文都会有异常
    //假定是在unicode环境下
    setlocale(LC_ALL, "chs"); //使用它下面显示中文正常
    wchar_t wstr[] = L"中a文BBcc";
    ATLTRACE(L"my Char :%s\r\n",wstr);
    ATLTRACE("my Char :%S\r\n",wstr); //注意这里在大S