locked
CMFCPropertyGridProperty float formating RRS feed

  • Question

  • Hi. I'm building an MFC app with VC++ 2008, but I'm having a little trouble. I've a CDockablePane with a property list, similar to the NewControls example that comes with the MFC Feature Pack. However, some of my properties are 'float' and I would like to format them with 2 decimal number (e.g. 34.56).

    It seemed that the only thing I needed to do was set the following variable:

    CMFCPropertyGridProperty::m_strFormatFloat = _T("%.2f");

    This works as long as the property isn't manually updated. When the value is updated it triggers a breakpoint cause of the 'invalid format'.

    Here's the stack.

         msvcr90d.dll!_CrtDbgBreak()  Line 89    C
         msvcr90d.dll!_VCrtDbgReportW(int nRptType=2, const wchar_t * szFile=0x1020dcd0, int nLine=1379, const wchar_t * szModule=0x00000000, const wchar_t * szFormat=0x1020dda0, char * arglist=0x00123d10)  Line 505    C
         msvcr90d.dll!_CrtDbgReportWV(int nRptType=2, const wchar_t * szFile=0x1020dcd0, int nLine=1379, const wchar_t * szModule=0x00000000, const wchar_t * szFormat=0x1020dda0, char * arglist=0x00123d10)  Line 241 + 0x1d bytes    C++
         msvcr90d.dll!_CrtDbgReportW(int nRptType=2, const unsigned short * szFile=0x1020dcd0, int nLine=1379, const unsigned short * szModule=0x00000000, const unsigned short * szFormat=0x1020dda0, ...)  Line 42 + 0x1d bytes    C++
         msvcr90d.dll!_winput_s_l(_iobuf * stream=0x001240dc, const wchar_t * format=0x00348502, localeinfo_struct * plocinfo=0x00000000, char * arglist=0x0012413c)  Line 1379 + 0x47 bytes    C++
         msvcr90d.dll!vscan_fn(int (_iobuf *, const wchar_t *, localeinfo_struct *, char *)* inputfn=0x102a0bc0, const wchar_t * string=0x01052318, const wchar_t * format=0x00348500, localeinfo_struct * plocinfo=0x00000000, char * arglist=0x00124138)  Line 66 + 0x13 bytes    C
    >    msvcr90d.dll!swscanf_s(const wchar_t * string=0x01052318, const wchar_t * format=0x00348500, ...)  Line 232 + 0x18 bytes    C
         mfc90ud.dll!CMFCPropertyGridProperty::TextToVar(const ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > & strText="606.03")  Line 1192 + 0x1e bytes    C++
         mfc90ud.dll!CMFCPropertyGridProperty::OnUpdateValue()  Line 1140 + 0x14 bytes    C++
         mfc90ud.dll!CMFCPropertyGridCtrl::EndEditItem(int bUpdateData=1)  Line 3877 + 0x39 bytes    C++
         mfc90ud.dll!CMFCPropertyGridCtrl::OnEditKillFocus()  Line 4888 + 0x12 bytes    C++
         mfc90ud.dll!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x00fff72c, unsigned int nID=3, int nCode=512, void (void)* pfn=0x78cd88a0, void * pExtra=0x00000000, unsigned int nSig=57, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000)  Line 82    C++
         mfc90ud.dll!CCmdTarget::OnCmdMsg(unsigned int nID=3, int nCode=512, void * pExtra=0x00000000, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000)  Line 381 + 0x27 bytes    C++
         mfc90ud.dll!CWnd::OnCommand(unsigned int wParam=33554435, long lParam=1707274)  Line 2364    C++
         mfc90ud.dll!CWnd::OnWndMsg(unsigned int message=273, unsigned int wParam=33554435, long lParam=1707274, long * pResult=0x00124480)  Line 1769 + 0x1e bytes    C++
         mfc90ud.dll!CWnd::WindowProc(unsigned int message=273, unsigned int wParam=33554435, long lParam=1707274)  Line 1755 + 0x20 bytes    C++
         mfc90ud.dll!AfxCallWndProc(CWnd * pWnd=0x00fff72c, HWND__ * hWnd=0x001b0d1a, unsigned int nMsg=273, unsigned int wParam=33554435, long lParam=1707274)  Line 240 + 0x1c bytes    C++
         mfc90ud.dll!AfxWndProc(HWND__ * hWnd=0x001b0d1a, unsigned int nMsg=273, unsigned int wParam=33554435, long lParam=1707274)  Line 403    C++
         mfc90ud.dll!AfxWndProcBase(HWND__ * hWnd=0x001b0d1a, unsigned int nMsg=273, unsigned int wParam=33554435, long lParam=1707274)  Line 441 + 0x15 bytes    C++

    Anyone had this problem and figured out to fix it?
    Monday, December 8, 2008 8:58 PM

Answers