为什么我在使用 Format() 格式化的 CString 中得到无效数据?
LRESULT CFlashWnd::OnScannerProgress( WPARAM wParam, LPARAM lParam )
{
ScannerProgress *pEvent = (ScannerProgress *)wParam;
CString scannerAreaText = _T("");
scannerAreaText.Format(_T("<B>Scanning%3A</B> <font face='Arial' size='10'>%s</font>"), pEvent->pszScanner);
CString scanProgressText = _T("");
scanProgressText.Format(_T("<B>Scan Progress%3A</B> <font face='Arial' size='10'>%f</font>"), pEvent->dwScanPercent);
CString scanProgressBarValue = _T("");
scanProgressBarValue.Format(_T("%f%"), pEvent->dwScanPercent);
if(pEvent->pszScanItem)
free((void *)pEvent->pszScanItem);
if(pEvent->pszScanner)
free((void *)pEvent->pszScanner);
delete pEvent;
return 0;
}
我不断收到奇怪的值和/或崩溃。欢迎任何建议。
LRESULT CFlashWnd::OnScannerProgress( WPARAM wParam, LPARAM lParam )
{
ScannerProgress *pEvent = (ScannerProgress *)wParam;
CString scannerAreaText = _T("");
scannerAreaText.Format(_T("<B>Scanning%3A</B> <font face='Arial' size='10'>%s</font>"), pEvent->pszScanner);
CString scanProgressText = _T("");
scanProgressText.Format(_T("<B>Scan Progress%3A</B> <font face='Arial' size='10'>%f</font>"), pEvent->dwScanPercent);
CString scanProgressBarValue = _T("");
scanProgressBarValue.Format(_T("%f%"), pEvent->dwScanPercent);
if(pEvent->pszScanItem)
free((void *)pEvent->pszScanItem);
if(pEvent->pszScanner)
free((void *)pEvent->pszScanner);
delete pEvent;
return 0;
}
I keep getting funky values and/or crashes. Any suggestions are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请使用 %%3A,而不是 %3A。
Instead of %3A, use %%3A.
我不确定,但您应该仔细检查格式字符串中的 %3A 。如您所知,百分号表示占位符。
I'm not sure but you should double check the %3A in your format strings. The percent sign, as you know, indicates a placeholder.