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. File Change Event CDialog

File Change Event CDialog

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++comtutorialquestion
2 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.
  • P Offline
    P Offline
    picazo
    wrote on last edited by
    #1

    Hello, I am working on a project that requires file-change-notification to a CDialog. Currently, I am trying to use the CFileChangeEventClass[^] by Fanky Braem. However, when I get notified of a change, and I try to call UpdateData(), the program crashes. I believe that Franky explains what the problem is: "A thread can access only MFC objects that it created. This is because temporary and permanent Windows handle maps are kept in thread local storage to ensure protection from simultaneous access from multiple threads." and provides a solution for a doc/view scenerio. Can anyone help me in figuring out how to solve this for the CDialog case? Thanks a lot, ----------------- Genaro

    B 1 Reply Last reply
    0
    • P picazo

      Hello, I am working on a project that requires file-change-notification to a CDialog. Currently, I am trying to use the CFileChangeEventClass[^] by Fanky Braem. However, when I get notified of a change, and I try to call UpdateData(), the program crashes. I believe that Franky explains what the problem is: "A thread can access only MFC objects that it created. This is because temporary and permanent Windows handle maps are kept in thread local storage to ensure protection from simultaneous access from multiple threads." and provides a solution for a doc/view scenerio. Can anyone help me in figuring out how to solve this for the CDialog case? Thanks a lot, ----------------- Genaro

      B Offline
      B Offline
      Blake V Miller
      wrote on last edited by
      #2

      Do the file change notificaiton/waiting in a secodnary thread. Post messages to your main thread. Process those messages in the main thread. Don't try ot directly update controls from the secodnary thread which processed the file notification. You can look into ON_REGISTERED_MESSAGE. // example for ON_REGISTERED_MESSAGE const UINT wm_Find = RegisterWindowMessage( FINDMSGSTRING ); BEGIN_MESSAGE_MAP( CMyWnd, CMyParentWndClass ) ON_REGISTERED_MESSAGE( wm_Find, OnFind ) // ... Possibly more entries to handle additional messages END_MESSAGE_MAP( ) Post the registered message fromt he notiifcaiton thread. When the main dialog receives it, then call the updatedata. This should work fine for you.

      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