开发者

Why do I get invalid data in my CString formatted using Format()?

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>开发者_JS百科;"), 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.


Instead of %3A, use %%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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜