ATLTRACE怎么输出宽字符串?

qianwen36 2011-12-02 09:14:46
我打印过,ATLTRACE输出宽字符串有问题。怎么办?

宽字符串怎么打印到调试输出窗口中?
...全文
235 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ysjyniiq 2011-12-10
  • 打赏
  • 举报
回复
一般显示中文都会有异常


//假定是在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
qianwen36 2011-12-08
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 waistcoat06 的回复:]

那句异常了?
[/Quote]
m_ToolTip.MoveWindow(&rcTip);
OutputDebugString(toolInfo.lpsztext);
前一句MoveWindow异常了。
WaistCoat06 2011-12-02
  • 打赏
  • 举报
回复
那句异常了?
qianwen36 2011-12-02
  • 打赏
  • 举报
回复
为什么我这段代码执行不下去,报异常了。求助


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);
WaistCoat06 2011-12-02
  • 打赏
  • 举报
回复
OutputDebugStringW(L"xxxx");
fishion 2011-12-02
  • 打赏
  • 举报
回复
先用W2A转换成多字节
AtlBase.h

USES_CONVERSION;

LPCSTR x = W2A(lpsz);

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧