Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Dialog box continuous update?

Dialog box continuous update?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestionannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bradleyand
    wrote on last edited by
    #1

    I want to continually update the data in the edit boxes on my dialog box with data that is generated in a loop. For example: for( i=0; i<100; i++) { m_X += 1; UpdateData(FALSE); } However, when I try this it loops through the for loop and doesn't display the values until it reaches the end of the loop. Thats when it displays 100. Any help would be appreciated. Thanks

    A 1 Reply Last reply
    0
    • B bradleyand

      I want to continually update the data in the edit boxes on my dialog box with data that is generated in a loop. For example: for( i=0; i<100; i++) { m_X += 1; UpdateData(FALSE); } However, when I try this it loops through the for loop and doesn't display the values until it reaches the end of the loop. Thats when it displays 100. Any help would be appreciated. Thanks

      A Offline
      A Offline
      Andrey Del Pozo
      wrote on last edited by
      #2

      The problem is that the thread that executes your for loop is the same thread that draws the GUI of your app. In order to solve your problem you have to create a workerthread. That thread must have a way to comunicate with your gui. If your ussing MFC the safe way to do it is passing the HWND of the dialog box or the HWNDs of the controls you want to update and use SendMessage/PostMessage to update their contents. To create a worker thread ( a worker thread does not handle any UI events, it does not own a window ) you can call: CWinThread* AfxBeginThread( AFX_THREADPROC pfnThreadProc, LPVOID pParam, int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0, DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL ); pfnThreadProc - this is your thread function,it has the following proto: UINT MyControllingFunction( LPVOID pParam ); pParam - can be anything you want, and it is what you recive in pParam in MyControllingFunction (usualy in MFC a HWND) "I don't want to achieve immortality through my work... I want to achieve it through not dying." Woody Allen

      B 1 Reply Last reply
      0
      • A Andrey Del Pozo

        The problem is that the thread that executes your for loop is the same thread that draws the GUI of your app. In order to solve your problem you have to create a workerthread. That thread must have a way to comunicate with your gui. If your ussing MFC the safe way to do it is passing the HWND of the dialog box or the HWNDs of the controls you want to update and use SendMessage/PostMessage to update their contents. To create a worker thread ( a worker thread does not handle any UI events, it does not own a window ) you can call: CWinThread* AfxBeginThread( AFX_THREADPROC pfnThreadProc, LPVOID pParam, int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0, DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL ); pfnThreadProc - this is your thread function,it has the following proto: UINT MyControllingFunction( LPVOID pParam ); pParam - can be anything you want, and it is what you recive in pParam in MyControllingFunction (usualy in MFC a HWND) "I don't want to achieve immortality through my work... I want to achieve it through not dying." Woody Allen

        B Offline
        B Offline
        bradleyand
        wrote on last edited by
        #3

        thank for the info.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups