locked
Why doesnt static text on CDialog get updated? (Windows Mobile 6.53, Visual Studio 8, VC++) RRS feed

  • Question

  • I need to use MFC in a single dialog application in Windows Mobile 6.53? (Visual Studio 8, VC++)
    I am a Windows dev newbie and am finding it difficult to find information to do a simple GUI like this.

     My program does some processing work in the backround and updates a gui with the progress. One of the fields is an int counter that represents progress. I am able to Post a Message to the Dialog and the OnMessage handler runs. However, the field in the GUI does not update.

    LRESULT BarAppDlg::OnRecalcInProgress(WPARAM wParam, LPARAM)

    {

          CString cs;

          int m_foo = 99;

          cs.Format(_T("%d"), m_foo);

          foo_control.SetWindowTextW(cs);

          foo_value = m_foo;

          UpdateData(TRUE);

          return 0;

    }

    void BarAppDlg::DoDataExchange(CDataExchange* pDX)

    {

          CDialog::DoDataExchange(pDX);

          DDX_Control(pDX, IDC_STATIC_FOO, foo_control);

          DDX_Text(pDX, IDC_STATIC_FOO, foo_value);

    }

     

    The value of foo remains zero.

    Any help appreciated.

     

    Thursday, June 23, 2011 3:16 AM

Answers

  • Hello,

     

    Did your static text control handle is static value? As far as I know, if we want to access the controls in different threads, we need to set this control handle as a static value, otherwise we cannot use it in another thread directly.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    1) I thought threads share the same stack context?

    2) I changed CStatic to CEdit and now it gets updated.

    • Proposed as answer by Jesse Jiang Monday, July 4, 2011 9:33 AM
    • Marked as answer by Jesse Jiang Thursday, July 7, 2011 7:24 AM
    Monday, June 27, 2011 2:35 PM

All replies

  • Hello,

     

    Did your static text control handle is static value? As far as I know, if we want to access the controls in different threads, we need to set this control handle as a static value, otherwise we cannot use it in another thread directly.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, June 27, 2011 9:47 AM
  • Hello,

     

    Did your static text control handle is static value? As far as I know, if we want to access the controls in different threads, we need to set this control handle as a static value, otherwise we cannot use it in another thread directly.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    1) I thought threads share the same stack context?

    2) I changed CStatic to CEdit and now it gets updated.

    • Proposed as answer by Jesse Jiang Monday, July 4, 2011 9:33 AM
    • Marked as answer by Jesse Jiang Thursday, July 7, 2011 7:24 AM
    Monday, June 27, 2011 2:35 PM
  • Hi,

     

    I marked your reply as answer, if your issue have not been solved please unmark it and update more information about this issue.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, July 7, 2011 7:25 AM